AudioPlayer complete event?
Is there no "complete" event for Titanium.Media.AudioPlayer? I don't see one and after seeing Titanium.Media.Sound has one, i tried adding a listener for "complete" but to no avail. I find it strange that this isn't supported for AudioPlayer. Am I missing something?
3 Answers
-
For now I've worked around the complete event issue by checking the progress property after a stop event.
function playbackStateChange(e) { if (e.state == audioPlayer.STATE_STOPPED && audioPlayer.progress > 0) { // Track complete } } audioPlayer.addEventListener('change', playbackStateChange);
Still wish there was a complete event - this is a bit hacky. And still not seeing a way to get the total duration (before the track is complete). :(
-
You can fire an event on state change, and the integer of the stat will change when the stream is complete.
If I remember correctly, the complete state is "6".
Hope that helps.
Peter Janett
http://www.NewMediaOne.net
-
Fyi, I've found using the VideoPlayer is a good workaround for this since it also plays MP3s.