Results 1 to 2 of 2

Thread: Load pls file with QMediaPlaylist

  1. #1
    Join Date
    Apr 2014
    Posts
    116
    Thanks
    8
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Load pls file with QMediaPlaylist

    Hi there,

    I would like to load a pls file into my QMediaPlayer using QMediaPlaylist. First of all is pls supported? (I think so because I found a bug report but I am not sure)
    This is my code: (source is correct. Because if the source file is a m3u it works)
    Qt Code:
    1. AudioPlayer::AudioPlayer(QObject *parent) :
    2. QObject(parent){
    3. playlist = new QMediaPlaylist;
    4. player = new QMediaPlayer;
    5. }
    6.  
    7. void AudioPlayer::setSource(const QString &source){
    8. qDebug() << "Loading Playlist" << source;
    9. playlist->load(source);
    10. if(playlist->error())
    11. qDebug() << playlist->errorString();
    12. else
    13. qDebug() << "Playlist loaded";
    14. playlist->setCurrentIndex(1);
    15. player->setPlaylist(playlist);
    16. }
    To copy to clipboard, switch view to plain text mode 
    But I get the error that I provided an empty file. Can someone tell me what the proper way is to load a pls file?

    Thanks!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Load pls file with QMediaPlaylist

    You need to pass a valid QNetworkRequest, QUrl or QIODevice* to load() for your playlist. You are currently passing a string and relying on the QUrl conversion constructor's default behaviour to come up with a good URL.

    QMediaPlaylist contains a parser for PLS files so that should not be the problem.

Similar Threads

  1. How to load My own .cur file and set cursor
    By AKB48 in forum Qt Programming
    Replies: 2
    Last Post: 13th December 2016, 01:49
  2. Can Qwebview load xml/xsl file?
    By richardander in forum Qt Programming
    Replies: 3
    Last Post: 26th August 2015, 23:36
  3. Replies: 2
    Last Post: 12th May 2014, 15:06
  4. How to add QMediaPlaylist to a layout
    By adutzu89 in forum Newbie
    Replies: 2
    Last Post: 2nd December 2013, 09:06
  5. QMediaPlaylist view
    By Festus Hagen in forum Qt Programming
    Replies: 0
    Last Post: 6th September 2013, 08:23

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.