Music Streaming
This plugin allows you to stream audio from a server.
Limitations:
At this moment iOS (and simulator), macOS, android (read gottchas),and tvOS are only supported. Also please note you only can play one stream at a time (use musicStreaming.stop() before playing another song). Trying to play two will cause an error and crash. Also you can only stream http:// and https:// urls with this plugin.Gotchas: addToQueue does not work on android.
Please note "not playing" = you not calling musicStreaming.play() first
Functions:
musicStreaming.init()
sets things up
musicStreaming.play(url, listener)
--url (required)(string) the url of the string you would like to stream, example: "https://www.example.com/test1.mp3"
--listener (required)(function) lets you know when a song is started, finshed, or there is an error with the following event.response
- starting
- finished
- error loading song
musicStreaming.pause()
returns string, values "not playing", "already paused", or "pausing"
musicStreaming.stop()
returns string, values "not playing" or "stopped"
musicStreaming.resume()
returns string, values "not playing", "already playing",or "resume"
musicStreaming.getStatus()
returns string, values "not playing", "paused", "error" (this is rare),or "playing"
musicStreaming.getDuration()
how long is the song
returns number (note: using milliseconds)
musicStreaming.getProgress()
where are we in the song
returns number (note: using milliseconds)
musicStreaming.getVolume()
returns number
musicStreaming.setVolume(volume)
--volume (required) (integer) 0 = mute, 1= loudest, default is 1.
musicStreaming.addToQueue(url)
This allows you to play audio back to back without a gap. Note on android this has not been added due to technical limitations. I am working on a workaround.
--url (required)(string) the url of the string you would like to stream after song is finshed, example: "https://www.example.com/test1.mp3"
returns string, values "not playing" or "added to queue"
musicStreaming.seek(seekNum)
--seekNum (required)(integer)where you would like to go in the song (note: using milliseconds)returns string, values "not playing" or "seeking"
musicStreaming.checkAudio(url, listener) (only works iOS, tvOS, and MacOS)
--url (required)(string) url to check
--listener (required)(function) returns strings:
- song found
- error loading song
Android:
please note that audio will play in background by default. Please use system events to .pause() the music with "applicationSuspend".
iOS:
While there is a way on iOS, it is not offical supported by corona. So use at your own risk
Example found here
Build.settings
Credits:
streaming kit by Thong Nguyen was used for for iOS, Mac, and tvOs