Page 1 of 1

mobileControlGet (ID/or Name, "duration")

Posted: Wed May 24, 2023 12:26 am
by MxDx
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