play audiofile from web server

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
per_bodelius
Posts: 20
Joined: Mon Mar 19, 2018 11:25 pm

play audiofile from web server

Post by per_bodelius » Mon Mar 26, 2018 5:28 pm

Hi there,
Can anybody tell me how I can play an audiofile from an url on iphone and android. If I test the following,
play "<domain-name>/.../sound/math002.aiff", it works well when I try it on PC and Mac.I can´t find anything about this in the LIveCode documentation.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: play audiofile from web server

Post by MaxV » Tue Mar 27, 2018 3:12 pm

I think that on mobile you have to use or the browser or the player object.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

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

Re: play audiofile from web server

Post by Klaus » Tue Mar 27, 2018 4:00 pm

"player" objects are desktop-only and not available on the mobile platform!

On mobile you need to use "mobilecontrolcreate" to create a mobile native "player" control.
Then you can use "mobilecontrolset" to set its filename to the url on your server.

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

Re: play audiofile from web server

Post by Klaus » Thu Mar 29, 2018 11:10 am

I moved this thread over to the beginners section, since it is really not OFF-TOPIC.

per_bodelius
Posts: 20
Joined: Mon Mar 19, 2018 11:25 pm

Re: play audiofile from web server

Post by per_bodelius » Mon Apr 02, 2018 12:34 pm

Hi Klaus,
I have tested to do as you said; "using mobileControlSet" , but I cannot get it working.,,
This is the code I have used:

on MouseDown
put "h t t p://www.<my domain.s e>/matteapp/sound/math002.mp3" into sLink
mobilecontrolCreate "player","mplayer"
mobileControlSet "mplayer","filename",sLink
mobileControlDo "mplayer", "play"
end MouseDown

Am I doing anything wrong with the code? I have also tested with different types of sound file (wav,mp3,aiff) and with different bitrate for mp3.

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

Re: play audiofile from web server

Post by Klaus » Mon Apr 02, 2018 5:36 pm

Hi Per,

I don't own a mobile device nor do I develop for mobile, but maybe you also need to set the rect and visible property? At least worth a try...

Code: Select all

on MouseDown
put "h t t p://www.<my domain.s e>/matteapp/sound/math002.mp3" into sLink
  mobilecontrolCreate "player","mplayer"
  mobileControlSet "mplayer","rect","0,0,100,20"
  mobileControlSet "mplayer","visible",TRUE

  ## And maybe:
  mobileControlSet "mplayer","showcontroller",TRUE
  mobileControlSet "mplayer","filename",sLink
  mobileControlDo "mplayer", "play"
end MouseDown
Best

Klaus

per_bodelius
Posts: 20
Joined: Mon Mar 19, 2018 11:25 pm

Re: play audiofile from web server

Post by per_bodelius » Tue Apr 03, 2018 12:13 am

Hi again Klaus!
Thanks for your time an engagement in this task, but unfortunately it didn't help...same result.
Maybe some other "Livecoder" has succeeded in using "mobilecontrolcreate" for playing audio on IOS devices.
I use LC Indy 8.1.9 (rc1) + Xcode 9.2 + MacOS 10.13.3

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: play audiofile from web server

Post by PaulDaMacMan » Fri Apr 20, 2018 8:41 pm

Klaus wrote:
Tue Mar 27, 2018 4:00 pm
"player" objects are desktop-only and not available on the mobile platform!

On mobile you need to use "mobilecontrolcreate" to create a mobile native "player" control.
Then you can use "mobilecontrolset" to set its filename to the url on your server.
I'm not sure that is the case, at least not with sound files on Android.
I've used:

Code: Select all

play theFile
on Android for a while now to play MIDI files generated with LiveCode. I would think it works with any media filetype supported by the OS but I haven't tested it with .aif files.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”