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

Ask about the individual Gambas components here.
Post Reply
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

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

Post by JumpyVB »

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.
Private myPlayer As New MediaPlayer As "myPlayer"
Public Sub Form_Open()
  myPlayer.SetWindow(DrawingArea1)
  myPlayer.URL = Media.URL("/home/user/first_vid.mp4")
  myPlayer.Play()
  ' myPlayer.Seek(...) ' Use this to save time if your video is long
End
Public Sub DrawingArea1_MouseDown()
  'This code to launch second video only works if the previous video was not let to reach the end.
  myPlayer.URL = Media.URL("/home/user/second_vid.mp4")
  myPlayer.Play()
End
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:
Private myPlayer As New MediaPlayer As "myPlayer"
Public Sub Form_Open()
  myPlayer.SetWindow(DrawingArea1)
  myPlayer.URL = Media.URL("/home/user/first_vid.mp4")
  myPlayer.NextURL = Media.URL("/home/user/second_vid.mp4")
  myPlayer.Play()
End
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

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

Post by JumpyVB »

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.
Public Sub myPlayer_AboutToFinish()
  myPlayer.Seek(0)
End
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

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

Post by BruceSteers »

did you try this to go to the start again...
Public Sub DrawingArea1_MouseDown()
  'This code to launch second video only works if the previous video was not let to reach the end.
  myPlayer.Stop()  
  myPlayer.URL = Media.URL("/home/user/second_vid.mp4")
  myPlayer.Play()
End


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...
https://gitlab.com/gambas/gambas/-/tree ... .form/.src
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

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

Post by BruceSteers »

the MediaView does do this...


Public Sub MediaPlayer_End()
  
  Stop()
  
End




Stop() should reset everything.
If at first you don't succeed , try doing something differently.
BruceS
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

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

Post by vuott »

JumpyVB wrote: Saturday 22nd April 2023 5:37am 1) When video playback reaches the end, I loose normal access to my instance of the MediaPlayer class.
Private myPlayer As New MediaPlayer As "myPlayer"

Public Sub Form_Open()
  myPlayer.SetWindow(DrawingArea1)
  myPlayer.URL = Media.URL("/home/user/first_vid.mp4")
  myPlayer.Play()
End

Public Sub DrawingArea1_MouseDown()
  'This code to launch second video only works if the previous video was not let to reach the end.
  myPlayer.URL = Media.URL("/home/user/second_vid.mp4")
  myPlayer.Play()
End
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 !

Amare memorentes atque deflentes ad mortem silenter labimur.
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

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

Post by JumpyVB »

vuott wrote: Sunday 23rd April 2023 12:27amFor 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?
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

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

Post by BruceSteers »

JumpyVB wrote: Sunday 23rd April 2023 8:54am Is there an alternative to gb.media in Gambas3 for showing video files?
Only a MovieBox (gb.gui) but no sound.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

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

Post by BruceSteers »

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.
If at first you don't succeed , try doing something differently.
BruceS
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

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

Post by vuott »

Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

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

Post by JumpyVB »

So many alternatives. Thank you vuott. I decide to go with libvlc.
However new questions arose: viewtopic.php?t=1530
Post Reply