Player control in iOS vs Android - duration and play start

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
okk
Posts: 176
Joined: Wed Feb 04, 2015 11:37 am

Player control in iOS vs Android - duration and play start

Post by okk » Mon Apr 19, 2021 5:23 pm

Hi,
i have created a mobile player control. I want to display a custom progressbar to indicate the progress of the movie. I use the following to get the values needed for calculating the width of my progressbar:

Code: Select all

put mobileControlGet("video", "currentTime") into timecode
put mobileControlGet("video", "duration") into duration
According to the dictionary:
"duration": returns the duration of a movie, measured in milliseconds. This is an integer value.
While I found this to be true for Android, for iOS the currentTime is given in my case in milliseconds but the duration is given in seconds. It is not a big deal but it took me a while to figure it out. Furthermore, can I trust that it will give the duration always in seconds? Can I force the player control to give me the duration of the clip in milliseconds?

A second issue is about the starting the video, since the videofiles are located on a wasabi server it might take a while before the video can start playing. What would be the most elegant way to deal with this delay between starting the video and the actual start of the playback? what I currently do when I want to show a video-clip is the following:

1. set the player control invisible
2. set the filename of the player control to filepath
3. start playback of player control
4. show spinner widget
5. send "showvideo" to me in 800 milliseconds
6. on showvideo: if currentTime of player is > 0 show player control, hide spinner widget, otherwise send "showvideo" to me in 50 milliseconds

It works very well on android, on iOS it crashes now and then, not sure what is the issue.
Thanks

Oliver

okk
Posts: 176
Joined: Wed Feb 04, 2015 11:37 am

Re: Player control in iOS vs Android - duration and play start

Post by okk » Thu Apr 22, 2021 11:24 am

I tested the player control for iOS a bit further, it behaves unreliably in my environment. LC 9.6.1 MacOSX 10.14.6 XCODE 11.13.1.
I attach a demostack. You need to open it in an iOS simulator, it wont work in the IDE. I use the Iphone 11 simulator.The pull down button allows to choose different video files. The videos are located on a wasabi server.

In the sample stack if you click "play LC" the script creates a player control, sets the properties, shows the control, initiates play etc. It always prints the completed activity into the info field with a bit of wait. The "close" button deletes the player control. Now, when I click "play LC", then "close" then "play LC" again and repeat this a few times, especially after changing the video file, the app crashes. It gets stuck after setting the filename and before starting playback.

When using MergAV the same doesnt happen. Can anyone recreate the same behaviour?

Btw. I was also wondering which player control is more actively developed, the native one or MergAV?

Thanks
Oliver
Attachments
video_test_ios.livecode.zip
(2.94 KiB) Downloaded 214 times

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Player control in iOS vs Android - duration and play start

Post by jiml » Fri Apr 23, 2021 6:28 pm

Have you tried using just one player and simply changing the file it points to?

okk
Posts: 176
Joined: Wed Feb 04, 2015 11:37 am

Re: Player control in iOS vs Android - duration and play start

Post by okk » Fri Apr 23, 2021 6:45 pm

Hi,
I have tried all kind of things. But I just figured out that it is a known bug for iOS.
https://quality.livecode.com/show_bug.cgi?id=22650
But the MergAV workaround is okay.

Best
oliver

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Player control in iOS vs Android - duration and play start

Post by jiml » Sat Apr 24, 2021 9:17 pm

Does setting the filename to empty prior to setting it to a new filename help?

Code: Select all

  mobileControlSet "TestPlayer", "filename", ""
  wait 2 ticks
  mobileControlSet "TestPlayer", "filename", "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"

okk
Posts: 176
Joined: Wed Feb 04, 2015 11:37 am

Re: Player control in iOS vs Android - duration and play start

Post by okk » Sun Apr 25, 2021 9:39 am

Hi Jimi,
setting the filename to empty doesn't have any effect. From my expereince this empty filename trick is only needed with the player object when deploying to desktop, but not with the player mobile control. In any case, the bug is recognized by the LC team and a fix is apparently scheduled for LC 9.6.3. viewtopic.php?f=49&t=35247
And my app works now reliably without any crash with MergAV. I just needed to create a custom controller.

Thanks!
Oliver

Post Reply

Return to “Multimedia”