mobileControlGet (ID/or Name, "duration")

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MxDx
Posts: 9
Joined: Mon Apr 17, 2023 2:49 am

mobileControlGet (ID/or Name, "duration")

Post by MxDx » Wed May 24, 2023 12:26 am

LC 9.6.9 | Mac OS 11.7.6

Is this a bug?
The code below successfully creates and plays the selected file.
But I can't get the duration of the loaded file until AFTER the play command is issued.

Code: Select all

mobileControlCreate "player", "aPlayer"
put mobileControlGet ("aPlayer", "id") into gAndPlayerID
mobileControlSet gAndPlayerID, "visible", true
mobileControlSet gAndPlayerID, "rect", "4,  4, 363, 285" 
mobileControlSet gAndPlayerID, "showController", false

mobileControlSet gAndPlayerID, "filename", gSelectedMedia   
-- calling this function at this point doesn't return the player duration
-- confused because the file is loaded so why wouldn't the duration be know?
put mobileControlGet (gAndPlayerID, "duration") into field "theDuration"  -- returns -1

-- after the play command the duration is returned as expected.
mobileControlDo gAndPlayerID, "play"
put mobileControlGet (gAndPlayerID, "duration") into field "theDuration" -- returns the correct duration
thanks in advance

Post Reply

Return to “Android Deployment”