Recent

Author Topic: libmpv media player control  (Read 10746 times)

Espectr0

  • Full Member
  • ***
  • Posts: 240
Re: libmpv media player control
« Reply #15 on: January 02, 2024, 10:11:02 pm »
Here is video with testing after your changes:
https://youtu.be/dcEurLpuWV0

Testing began after windows restart.
As you can see:

1st launch after restart:
  - rmOpenGL does not work, every video is embedded
2nd and other launches
  - rmOpenGL works until m4b file is opened for the second time (no other testing file caused this)
  - rmEmbedding works well in my opinion

Both rendering modes should display the video in our component.
With rmEmbedding mode, we simply tell mpv to create the window inside our component (the easy and fast way).
In the case of rmOpenGL, we are in charge of directly drawing the image in our component, and in the tests I did, it is the only way I can "embed" mpv in macOS.

We would have to see why it fails for you with OpenGL sometimes.

I use rmEmbedding on Windows and rmOpenGL on Linux/macOS.

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: libmpv media player control
« Reply #16 on: January 02, 2024, 11:48:15 pm »
Okay, now I understand.

rmEmbedding is Native window embedding method according to
https://github.com/mpv-player/mpv-examples/tree/master/libmpv#methods-of-embedding-the-video-window
and rmOpenGL is Render API method from the same document.

Espectr0

  • Full Member
  • ***
  • Posts: 240
Re: libmpv media player control
« Reply #17 on: January 03, 2024, 12:32:45 pm »
Ok, I'm going to modify it so that it doesn't play if it fails to start rmOpenGL.
It could also be, if it fails with rmOpenGL switch to rmEmbedding.

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: libmpv media player control
« Reply #18 on: January 03, 2024, 01:27:31 pm »
I would argue in favor of not playing if render initiation fails.
Or use another flag as published property, for example something like Backup Render, to indicate which render use in case of failing the first one.
What do you think about it?

Espectr0

  • Full Member
  • ***
  • Posts: 240
Re: libmpv media player control
« Reply #19 on: January 03, 2024, 10:42:56 pm »
I think for now try not to play anything if it fails, and then we'll see  8-)

domasz

  • Hero Member
  • *****
  • Posts: 626
Re: libmpv media player control
« Reply #20 on: January 04, 2024, 08:50:41 pm »
How can I go fullscreen? I thought:
Code: Pascal  [Select][+][-]
  1. BorderStyle := bsNone;
  2. MPV.Align := alClient;
should do the trick but the image goes black.

Espectr0

  • Full Member
  • ***
  • Posts: 240
Re: libmpv media player control
« Reply #21 on: January 05, 2024, 12:26:34 am »
it should work, stop playing?

domasz

  • Hero Member
  • *****
  • Posts: 626
Re: libmpv media player control
« Reply #22 on: January 05, 2024, 07:21:38 am »
Stopping doesn't help. Here's the code

Espectr0

  • Full Member
  • ***
  • Posts: 240
Re: libmpv media player control
« Reply #23 on: January 05, 2024, 11:47:04 am »
You are right. I think it doesn't work because when we init mpv, we embed it using the handle of our component, when we change the BorderStyle, the handle changes, then mpv fails/crash, so we would have to restart mpv.

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: libmpv media player control
« Reply #24 on: January 05, 2024, 07:08:35 pm »
I tested your last commit:

https://github.com/URUWorks/UW_MPVPlayer/commit/a7d2dc1c29c01be0c50dab3a30e6e81fca2bfddf

and the situation is the same. rmOpenGL works embedded for all tested files (mp4, mp3) only if m4b file is loaded twice.

domasz

  • Hero Member
  • *****
  • Posts: 626
Re: libmpv media player control
« Reply #25 on: January 06, 2024, 11:53:06 am »
You are right. I think it doesn't work because when we init mpv, we embed it using the handle of our component, when we change the BorderStyle, the handle changes, then mpv fails/crash, so we would have to restart mpv.
I tried putting MPV on a TPanel but same thing. And restarting MPV might be an option when playing a file from disk but in case of files from the web it will take too long.

Here's the best thing I have:

Code: Pascal  [Select][+][-]
  1. //hide every component on TForm except MPV
  2.   Panel3.Hide;
  3.   StatusBar1.Hide;
  4.  
  5. //calculate widths of TForm window's borders
  6.   P := Form1.ClientToScreen(Point(0,0));
  7.   R := Point(Left, Top);
  8.  
  9.   LeftMargin := P.X-R.X;
  10.   TopMargin := P.Y-R.Y - MainMenu1.Height;
  11.  
  12.   Menu := nil;
  13.  
  14. //save original (current) position, so when user leaves fullscreen we can set these values
  15.   OrgPos := Point(Left, Top);
  16.   OrgSize := Point(Width, Height);
  17.  
  18. //offset TForm window by the calculated borders' widths
  19.   Constraints.MaxHeight:= Screen.Height*2;
  20.   Constraints.MaxWidth := Screen.Width*2;
  21.  
  22.   Left := -LeftMargin;
  23.   Top := -TopMargin;
  24.  
  25.   Width := Screen.Width;
  26.   Height := Screen.Height;  
  27.  
  28.   FormStyle := fsSystemStayOnTop;  
  29.  

On multi-monitor setups it might give not-optimal results.
« Last Edit: January 08, 2024, 05:24:07 pm by domasz »

Espectr0

  • Full Member
  • ***
  • Posts: 240
Re: libmpv media player control
« Reply #26 on: January 06, 2024, 08:39:35 pm »
I tested your last commit:

https://github.com/URUWorks/UW_MPVPlayer/commit/a7d2dc1c29c01be0c50dab3a30e6e81fca2bfddf

and the situation is the same. rmOpenGL works embedded for all tested files (mp4, mp3) only if m4b file is loaded twice.

I can't reproduce the failure on my system, but added "RenderFailAction" with two options, rfSwitchToEmbedding or rfNone.
I wouldn't know if it works either  :-[

Espectr0

  • Full Member
  • ***
  • Posts: 240
Re: libmpv media player control
« Reply #27 on: January 06, 2024, 08:46:13 pm »
I tried putting MPV on a TPanel but same thing. And restarting MPV might be an option when playing a file from disk but in case of files from the web it will take too long.

Yes, but it's the only way I can think of.

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: libmpv media player control
« Reply #28 on: January 07, 2024, 06:49:34 pm »
I tested your last commit:

https://github.com/URUWorks/UW_MPVPlayer/commit/a7d2dc1c29c01be0c50dab3a30e6e81fca2bfddf

and the situation is the same. rmOpenGL works embedded for all tested files (mp4, mp3) only if m4b file is loaded twice.

I can't reproduce the failure on my system, but added "RenderFailAction" with two options, rfSwitchToEmbedding or rfNone.
I wouldn't know if it works either  :-[

It works!  :)  And even RenderFailAction is not needed for it. I split your last commit and added all changes which solved my issue to: https://github.com/zbyna/UW_MPVPlayer/commit/f3629455b8e7a497164cca594cbbf7697996c46f?diff=unified&w=1
in my repository. Branch "without_issue" works well for me. I mean embedded player using rmOpenGL  render mode in Windows 10.

Thank you very much for fixing this issue!

Espectr0

  • Full Member
  • ***
  • Posts: 240
Re: libmpv media player control
« Reply #29 on: January 07, 2024, 09:35:17 pm »
Good to Know! :D

 

TinyPortal © 2005-2018