MediaView questions
Posted
#1
(In Topic #1415)
Regular

On a side note, what is the difference between MediaView and MediaPlayer? Seems like MediaPlayer is more robust according to the wiki. Maybe I should be using that for seek/resume?
Posted
Guru

Only if you use MediaView.Stop will it not resume and start from the beginning
(Or maybe if you set MediaView.URL again in the play method)
The following code works exactly as expected for me.
(Post your code so we can see the problem)
Code (gambas)
MediaView.Position is read/write , it returns the position or sets the position. (but you shouldn't need it for pause/play)
MediaView is a ready made player using MediaPlayer.
I would not say MediaPlayer is more robust but i would say it's easier to use MediaView unless you want more control than MediaView gives then go for MediaPlayer.
Posted
Regular

BruceSteers said
Mediaview.Pause does pause it and resume where it left of when using MediaView.Play.
Only if you use MediaView.Stop will it not resume and start from the beginning
(Or maybe if you set MediaView.URL again in the play method)
The following code works exactly as expected for me.
(Post your code so we can see the problem)Code (gambas)
MediaView.Position is read/write , it returns the position or sets the position. (but you shouldn't need it for pause/play)
MediaView is a ready made player using MediaPlayer.
I would not say MediaPlayer is more robust but i would say it's easier to use MediaView unless you want more control than MediaView gives then go for MediaPlayer.
Thanks Bruce. I've shut everything down for the day. I will double check my code tomorrow and report back.
Posted
Regular

Posted
Guru

you have seen the wiki correct.
Maybe you have some other code making it go wrong.
post the project so we can see where the error is.
Posted
Guru

Code (gambas)
- ' save URL and position
- ' Resume play from last file/position
- MediaView1.URL = sFile
- MediaView1.Play
Posted
Guru

Seems we have to wait for the media to be initialized and start playing before you can set position.
(I had a similar problem many moons ago trying to read the .Duration property that did not fill until playback had actually started playing)
Code (gambas)
- ' Resume play from last file/position
- MediaView1.URL = sFile
- MediaView1.Play ' start playback
- Wait 0.1
Posted
Guru

MediaView, Setting Position before playback now works as expected (!387) · Merge requests · Gambas / gambas · GitLab
If Benoit thinks the fix is correct he will apply it, if not he will likely fix it correctly. (although i think he's going to be away from home for a little while)
Either way we'll find the cure
I have attached a fixed MediaView component,
To use it..
Extract the archived MediaView folder to your projects ".src/" folder.
Then goto project properties/components and un-select gb.form.media to stop using the gambas built in version.
then this code will work as we both expect it to
Code (gambas)
- MediaView1.URL = sFile
- MediaView1.Play
EDIT:
I just updated the archive.
I realized the $fStartUp variable was not reset to zero when it may or may not be set again.
So where it may or may not be set i have just set it to zero before hand in the SetPosition() procedure.
Posted
Regular

This app is turning out to be pretty cool looking and fun to build.
Posted
Guru

Trying to change .Position before the file has started playing and filled the .Duration property is where the .Position bug happens.
Just using Wait 0.5 may be a bit hit or miss.
So something like this i think should handle it better…
Posted
Regular

BruceSteers said
it seems very dependent on the fact .Duration has not yet been set.
Setting .Position before the file has started playing and set .Duration is where the .Position bug happens.
Just using Wait 0.5 may be hit or miss.
So something like this should handle it better…
Ok. I will adjust my code with the While Not you added. Thanks Bruce!
1 guest and 0 members have just viewed this.


