Help to display mp3 duration and played time in i0S

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
gwin
Posts: 3
Joined: Fri Mar 06, 2015 10:23 am

Help to display mp3 duration and played time in i0S

Post by gwin » Fri Mar 06, 2015 10:47 am

Hi!

I am trying to build a basic PLAY function inside an app for a short mp3 file on iOS.

I have no idea how to customise the native player hence I am using custom icons to play/pause/stop and need help displaying duration and amount played on the card.

Code: Select all

// set up the player
mobileControlSet "myPlayer", "filename", specialFolderPath("engine") & "/filetoplay.mp3"
mobileControlSet "myPlayer", "preserveAspect", true
mobileControlSet "myPlayer", "showController", true

// hide native player as controlling mp3 with custom icons
mobileControlSet "myPlayer", "visible", false

# for testing, display native player on card - works fine
# mobileControlSet "myPlayer", "rect", "10,400,300,370"
Setting up the play / pause / stop icons is straightforward with code such as...

Code: Select all

on mouseUp
   mobileControlDo "myPlayer", "play"
end mouseUp
But I cannot work out how to display;

1. The total length of the mp3 file in mins & secs, e.g. 1:02
2. The amount of the file played, i.e. counting up how much of the file has been played in realtime.

I have studied mobileControlGet and tried a myriad of patterns but can't seem to work it out.

Code: Select all

put mobileControlGet ("myPlayer","currentTime") into tcurrentTime   
put mobileControlGet ("myPlayer","playableDuration") into tDuration

put tDuration into fld "test"
Any help, pointers would be most appreciated. Thank you!

gwin
Posts: 3
Joined: Fri Mar 06, 2015 10:23 am

Re: Help to display mp3 duration and played time in i0S

Post by gwin » Fri Mar 06, 2015 11:23 am

OK! After all that, JUST found this post which should answer my questions: http://forums.livecode.com/viewtopic.php?f=10&t=3171

Having worked through the post quoted above, just need clarification on the equivalents for iOS of...

Code: Select all

   put the duration of player "p1" into tDuration
   put the timescale of player "p1" into tTimeScale
Should be something like...

Code: Select all

put mobileControlGet ("myPlayer","playableDuration") into tDuration
put mobileControlGet ("myPlayer","currentTime") into tTimeScale
Any ideas?

Klaus
Posts: 13858
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Help to display mp3 duration and played time in i0S

Post by Klaus » Sat Mar 07, 2015 12:39 pm

Hi gwin,

acording to the docs, all "times" for players are returned in milliseconds, so "timescale" is not needed at all!

QuickTIme movies on the desktop may have different timescales so you need to compute their "frame per second",
which is obviously not neccessary on iOS! Know what I mean?


Best

Klaus

Post Reply

Return to “Multimedia”