Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Is it possible to play a remote mp3 playlist

I'm trying to find an example of playing a list of MP3s from server on my iphone.

Is it possible to get m3u or pls files to play? Has anyone had luck getting them to play with a progress bar and the ability to go forward and back to play the next or previous files?

Any feedback appreciated

— asked November 3rd 2010 by Dave F
  • audio
  • iphone
  • playlist
  • sound
0 Comments

7 Answers

  • The audio streaming does not support natively reading m3u or pls files. Since they are text files, you could load them yourself and process them. I have been meaning to work on some code to do this for a project I am working on but haven't gotten around to it yet but I do not believe it will be difficult.

    — answered November 3rd 2010 by John McKnight
    permalink
    1 Comment
    • Hey John. Thanks so much for the quick reply. So aside from the m3u and pls formats, how can I get a list of mp3s to play in order while the app is in the background? I was actually only asking about m3u and pls files because I assumed that was the easier way to do it, but really I have a list of mp3 files that I want to play in whatever order they are in while in the background. Any help is appreciated.

      Thanks!

      — commented November 3rd 2010 by Dave F
  • Hey John. Thanks so much for the quick reply. So aside from the m3u and pls formats, how can I get a list of mp3s to play in order while the app is in the background? I was actually only asking about m3u and pls files because I assumed that was the easier way to do it, but really I have a list of mp3 files that I want to play in whatever order they are in while in the background. Any help is appreciated.

    Thanks!

    — answered November 3rd 2010 by Dave F
    permalink
    0 Comments
  • I did a little more testing… I'm not sure if this is the best method, but what i tried was creating an HTML file and embedded a quicktime player into it. I then used qtnext1,qtnext2,qtnext3… to define the files to play.

    This actually played in the background in succession. I could control the audio playback with the locked iphone and dock controls as well. I could PAUSE and ADVANCE the tracks… The only thing I could NOT do was go to a previous track.

    Interesting results. I wonder if anyone else has a better method. Ideally I'd love to lose the big black quicktime player and create my own that runs in a small window on the playlist page. But I'm not sure thats possible but i'm hoping in some way it is maybe using Titanium.Media.AudioPlayer or similar.

    Here's the html code I used and called into a webview
    http://pastie.org/1268527

    Any feedback is appreciated.

    — answered November 3rd 2010 by Dave F
    permalink
    0 Comments
  • You should be able to use MusicPlayer to set a series of mp3's to play. You could also use AudioPlayer and hook to the change event so you can be notified when one mp3 has stopped playing so you can queue up another mp3.

    If you look at this link you can download (if it is still available) some code that shows a queue of mp3. I know the post is about a bug but it only seems to affect short (under 1 second) mp3 files and the code sample he posted is a good start.

    — answered November 3rd 2010 by John McKnight
    permalink
    0 Comments
  • Interesting. So would the "complete" listener fire even in the background. I just assumed it wouldnt. Also I would think that the LOCKED and DOCK audio controls wouldnt work in this case but I'll do some testing tomorrow and see if I can get something to fly. Thanks for the feedback John.

    Fish

    — answered November 3rd 2010 by Dave F
    permalink
    0 Comments
  • Yes. You should be able to monitor the complete and switch files and it will run in the background.

    — answered November 3rd 2010 by John McKnight
    permalink
    0 Comments
  • Had some success implementing the audio to play in order. It jumps to the next track even when playing in the background, but the only thing that doesnt working is the BACK and NEXT buttons on the lock and dock screens (which I had expected when implementing this way - using an array of mp3s and calling the next one when one finishes)

    So now my question is, how to I create a playlist that plays audio in the background that is both controllable from the system dock and lock screens and also NOT a full screen quicktime player (which prevents the user from continuing to use the other sections of the app.)

    Basically I'm looking for playlist functionality that is similar to the NPR app (see 3rd screenshot) where the playlist is in a table view and the audio player (with controls) is in an independent window below the table and also plays in the background.

    Is there a way to hook into the system audio back and next controls on the lock and dock screens when using the following? or should I be using something else?

    snd = Ti.Media.createSound({
       url: fname,
       audioSessionMode:Ti.Media.AUDIO_SESSION_MODE_PLAYBACK
    });
    

    Thx to all

    — answered November 5th 2010 by Dave F
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.