Hi Jacque,

wonderful, thank you very much!
Will test this and report back.

> Am 23.10.2023 um 21:45 schrieb J. Landman Gay via use-livecode 
> <use-livecode@lists.runrev.com>:
> 
> On 10/22/23 7:34 AM, Klaus major-k via use-livecode wrote:
>> I'm having problems to play a MP3 (5 MB) from my server. And yes, I waited 
>> up to a minute before I closed the app. Works fine when I play it locally.
> 
> 
> Below is the script I use for mobile players. It's old so things may be 
> different now, but if I remember right I had to check playerPropertyAvailable 
> for the duration to be sure the player had enough content to start playing.
> 
> on createMobileAudioPlayer pURL, pPlayerName
>  -- pURL = remote video or audio file
>  -- pPlayerName = name of player to create; if empty uses LC-assigned ID
>  if sPlayerID is in mobileControls() then mobileControlDelete sPlayerID -- 
> init
>  if pPlayerName = "" then
>    mobileControlCreate "player"
>    put the result into sPlayerId
>  else
>    mobileControlCreate "player",pPlayerName
>    put pPlayerName into sPlayerID
>  end if
>  mobileControlSet sPlayerId, "rect", getPlayerRect() -- can use a literal 
> rect instead
>  mobileControlSet sPlayerId, "showController", true
>  mobileControlSet sPlayerId, "filename", pURL
>  mobileControlSet sPlayerId, "visible", true
>  if pURL begins with "http" then
>    mobileBusyIndicatorStart "square", "Loading..." -- add loading indicator 
> until duration is available
>  end if
> end createMobileAudioPlayer
> 
> on playerPropertyAvailable pProperty -- msg sent when enough content is loaded
>  if pProperty is "duration" then
>    mobileBusyIndicatorStop -- Remove the "Loading..." indicator and start 
> playing
>    mobileControlDo sPlayerId, "play"
>  end if
> end playerPropertyAvailable
> 
> on setMobileAudioPlayer pPlayerName,pState -- control the state of the mobile 
> player
>  -- pState = "pause", "play", or "stop"
>  if pPlayerName is not among the lines of mobileControls() then exit 
> setMobileAudioPlayer
>  mobileControlDo pPlayerName, pState
>  if pState = "stop" then
>    mobileBusyIndicatorStop -- in case it's still showing
>    mobileControlSet pPlayerName, "visible", false
>    mobileControlDelete pPlayerName
>  end if
> end setMobileAudioPlayer
> 
> on playerFinished -- sent on mobile when audio is done
>  setMobileAudioPlayer "stop"
> end playerFinished
> 
> -- 
> Jacqueline Landman Gay         |     jac...@hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com

Best

Klaus

--
Klaus Major
https://www.major-k.de
https://www.major-k.de/bass
kl...@major-k.de


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to