Can someone please confirm this weird behaviour in gb.media?

Post

Posted
Rating:
#1 (In Topic #1031)
Regular
JumpyVB is in the usergroup ‘Regular’
1) Use of MediaPipeline ja MediaPlayer seems to work only as long as I prevent the video playback from reaching the end. When video playback reaches the end, I loose normal access to my instance of the MediaPlayer class. The behaviour and the problem is also present with the base class MediaPipeline, so I swithed my example code here to MediaPlayer to simplify things for the sake of asking help here on gambas one forum.

Code (gambas)

  1. Private myPlayer As New MediaPlayer As "myPlayer"
  2. Public Sub Form_Open()
  3.   myPlayer.SetWindow(DrawingArea1)
  4.   myPlayer.URL = Media.URL("/home/user/first_vid.mp4")
  5.   myPlayer.Play()
  6.   ' myPlayer.Seek(...) ' Use this to save time if your video is long
  7. Public Sub DrawingArea1_MouseDown()
  8.   'This code to launch second video only works if the previous video was not let to reach the end.
  9.   myPlayer.URL = Media.URL("/home/user/second_vid.mp4")
  10.   myPlayer.Play()
Can someone please confirm this weird behaviour? Could this be a bug Benoit Minisini might be willing to fix?


2) I also tried another aproach. I would expect this to second code to play two files one after the other. Unfortunately the playback stops at the end of the first video:

Code (gambas)

  1. Private myPlayer As New MediaPlayer As "myPlayer"
  2. Public Sub Form_Open()
  3.   myPlayer.SetWindow(DrawingArea1)
  4.   myPlayer.URL = Media.URL("/home/user/first_vid.mp4")
  5.   myPlayer.NextURL = Media.URL("/home/user/second_vid.mp4")
  6.   myPlayer.Play()
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
JumpyVB is in the usergroup ‘Regular’
Also one option to solve my needs would be having the current video to loop indefinately.

With this code I can loop once. But that's it. And it's not very reliable as the event won't fire if I used seek to get near the end of the video. Anyway for the second looping of the video it will freeze and I loose control for myPlayer nomatter what.

Code (gambas)

  1. Public Sub myPlayer_AboutToFinish()
  2.   myPlayer.seek">Seek(0)
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
did you try this to go to the start again…

Code (gambas)

  1. Public Sub DrawingArea1_MouseDown()
  2.   'This code to launch second video only works if the previous video was not let to reach the end.
  3.   myPlayer.Stop()  
  4.   myPlayer.URL = Media.URL("/home/user/second_vid.mp4")
  5.   myPlayer.Play()
  6.  

Also there is the myPlayer_End() event that fires when playback ends.
you can unload/reload media with that.

check out the MediaView source to see how Benoit does it…
comp/src/gb.media.form/.src · master · Gambas / gambas · GitLab
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
the MediaView does do this…

Code (gambas)

  1.  
  2. Public Sub MediaPlayer_End()
  3.  
  4.   Stop()
  5.  
  6.  
  7.  
  8.  

Stop() should reset everything.
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
vuott is in the usergroup ‘Regular’

JumpyVB said

1) When video playback reaches the end, I loose normal access to my instance of the MediaPlayer class.

Code (gambas)

  1. Private myPlayer As New MediaPlayer As "myPlayer"
  2.  
  3. Public Sub Form_Open()
  4.   myPlayer.SetWindow(DrawingArea1)
  5.   myPlayer.URL = Media.URL("/home/user/first_vid.mp4")
  6.   myPlayer.Play()
  7.  
  8. Public Sub DrawingArea1_MouseDown()
  9.   'This code to launch second video only works if the previous video was not let to reach the end.
  10.   myPlayer.URL = Media.URL("/home/user/second_vid.mp4")
  11.   myPlayer.Play()
For me your code works: when the first video reached the end, by clicking on DrawingArea the second video starts regularly.
(I use QT graphic Component)

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
JumpyVB is in the usergroup ‘Regular’

vuott said

For me your code works: when the first video reached the end, by clicking on DrawingArea the second video starts regularly. (I use QT graphic Component)

Thank you for trying and reporting back. The problem must be related to the video files then.

I tried this again on my computer by making a new QT application but the behaviour is the same: myPlayer will simply stop responding to any attemps to load a new video file once the first video file has reached the end. I tried this in two different operating systems Linux Mint Cinnamon and EndeavourOs (with two different desktop environments Cinnamon and Plasma).

Then I tried random webm files downloaded from the internet. And they seem to work just fine without crashing at the end. I wonder what I could do next? The problem is present with all my home videos recorded using different android phones over the years (*.mp4 files) and a canon digital camera aswell (*.mov files). This might not be a Gambas issue but a GStreamer issue (although I have latest version on EdevourOS). Is there an alternative to gb.media in Gambas3 for showing video files?
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’

JumpyVB said

 Is there an alternative to gb.media in Gambas3 for showing video files?

Only a MovieBox (gb.gui) but no sound.
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’
 did you try MediaView ?

maybe your MediaPlayer code is wrong somewhere.
Try MediaView instead of MediaPlayer and see if that works?

If it does work then study differences as to why Benoits MediaView works and your code does not.
Online now: No Back to the top

Post

Posted
Rating:
#9
Regular
vuott is in the usergroup ‘Regular’

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#10
Regular
JumpyVB is in the usergroup ‘Regular’
So many alternatives. Thank you vuott. I decide to go with libvlc.
However new questions arose: https://forum.gambas.one/viewtopic.php?t=1530
Online now: No Back to the top
1 guest and 0 members have just viewed this.