Results 1 to 2 of 2

Thread: save music after played from url to local

  1. #1
    Join Date
    Nov 2010
    Posts
    30
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default save music after played from url to local

    hi

    i use this code to play music from Internet

    Qt Code:
    1. Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
    2. Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
    3. Phonon::createPath(mediaObject, audioOutput);
    4. Phonon::MediaSource source("http://mysite.com/001001.mp3");
    5. mediaObject->setCurrentSource(source);
    6. mediaObject->play();
    To copy to clipboard, switch view to plain text mode 

    how can i save 001001.mp3 in local after played..?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: save music after played from url to local

    find out a way to know the end of music playing, and then call download() as below, or just call download() after play()

    I am not sure of this but, can try
    Qt Code:
    1. download()
    2. {
    3. QNetworkReply * reply = QNetworkAccessManager::get ("http://mysite.com/001001.mp3");
    4. connect(reply, SIGNAL(readyRead()), this, SLOT(saveToFile());
    5. }
    6.  
    7. saveToFile()
    8. {
    9. QByteArray data = reply->readAll();
    10. QFile file("001001.mp3");
    11. if (!file.open(QIODevice::WriteOnly))
    12. return;
    13. file.write(data);
    14. file.close();
    15. reply->deleteLater();
    16. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Save a message in system store with QMessageService
    By grisson in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 16th May 2011, 10:06
  2. Background music
    By hema in forum Installation and Deployment
    Replies: 2
    Last Post: 20th April 2011, 04:43
  3. Replies: 8
    Last Post: 21st March 2011, 12:40
  4. How to find out what move file types can be played?
    By Markus in forum Qt Programming
    Replies: 3
    Last Post: 12th December 2010, 22:10
  5. How to save credentials in local keychain
    By kalos80 in forum Qt Programming
    Replies: 4
    Last Post: 9th November 2010, 11:08

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.