Results 1 to 7 of 7

Thread: Playing an mp3 while it is downloading

  1. #1
    Join Date
    Oct 2010
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Playing an mp3 while it is downloading

    i want to download the mp3 to a cache folder and play it at the same time
    maybe pause the playback just before a the end of the file and then play after a sufficient enough gap has been established (this would work so that the gap restriction is in effect from the start of playback giving initial buffer time)
    also what does MediaSource::MediaSource(const QUrl) do when it comes to buffering

    could someone give an example on how to do this

    i found this post but the method seems a little crude
    http://www.qtcentre.org/threads/3807...ownloading-it.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Playing an mp3 while it is downloading

    You should be able to play from a custom QIODevice - this should work in your case if the device is sequential.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2010
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Playing an mp3 while it is downloading

    i dont understand what you mean maybe you could give a small example

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Playing an mp3 while it is downloading

    Unfortunately there is no small example to give. You'd need to implement a subclass of QIODevice that would download the file from network (e.g. using QNetworkAccessManager) and feed it to Phonon at the same time saving it to disk.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2010
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Playing an mp3 while it is downloading

    Thanks for the reply
    i just want to know what the custom class should do when the player runs out of buffer
    should i implement a custom signal-slot to pause playback (or go into a buffering state).
    is it possible to know when only a certain ammount of buffer is left (like 512Kb)

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Playing an mp3 while it is downloading

    I'd imagine you would do the same as if the file was being retrieved from over the network (which is, in effect, what is happening)

    As for buffering, you would know that yourself. You will know how much of the file has been read and how much you have received from the network. However, I wouldn't worry about it, if you run out of data theres not much you can do.

    I'm not sure how well this kind of technique will work with MP3 files - typically you seek to the end of an MP3 to search for an ID3 tag before seeking back to the start to play the file. I don't know if Phonon does this, but if it does, maybe you would need to emulate this behavior (possibly with fake information, knowing the file type being retrieved of your I/O interface)

  7. The following user says thank you to squidge for this useful post:

    bittuthegr8 (7th March 2011)

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Playing an mp3 while it is downloading

    Quote Originally Posted by squidge View Post
    I'm not sure how well this kind of technique will work with MP3 files - typically you seek to the end of an MP3 to search for an ID3 tag before seeking back to the start to play the file. I don't know if Phonon does this, but if it does, maybe you would need to emulate this behavior (possibly with fake information, knowing the file type being retrieved of your I/O interface)
    The IO device needs to be sequential for all this to work thus you can't seek in the stream. In a general case it's possible to play an mp3 stream so here it should work too.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    bittuthegr8 (7th March 2011)

Similar Threads

  1. Playing file with Phonon while stil downloading it.
    By alexandernst in forum Qt Programming
    Replies: 3
    Last Post: 10th April 2011, 11:25
  2. About FTP uploading and downloading
    By prats in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2011, 11:28
  3. Downloading files
    By MTK358 in forum Newbie
    Replies: 3
    Last Post: 23rd June 2010, 00:08
  4. Problem with downloading a webpage
    By Fenix Voltres in forum Newbie
    Replies: 2
    Last Post: 25th June 2009, 19:55
  5. Downloading from a clean url
    By travlr in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2007, 21:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.