Results 1 to 5 of 5

Thread: HowTo read playlist pls file

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

    Default HowTo read playlist pls file

    Hi there,

    I would like to read a playlist .pls file to tell Audio what music to play but I cannot get QFile to read it. My application shall be an Sailfish app.
    To read a file I followed this tutorial.
    If I use this code with source: "qrc:/playlist.pls" (currently I provide the playlist within my resource file)
    Qt Code:
    1. FileIO {
    2. id: myFile
    3. source: "my_file.txt"
    4. onError: console.log(msg)
    5. }
    To copy to clipboard, switch view to plain text mode 
    I get this error:
    Qt Code:
    1. [W] unknown:39 - file:///usr/share/Test/qml/Test.qml:39:30: Type FirstPage unavailable
    2. initialPage: Component { FirstPage { } }
    3. ^
    4. [W] unknown:57 - file:///usr/share/Test/qml/pages/FirstPage.qml:57:21: Invalid property assignment: "source" is a read-only property
    5. source: "qrc:/playlist.pls"
    To copy to clipboard, switch view to plain text mode 
    I do not understand that because I only want to open the file as read-only, so why is the string invalid?

    Then I commented the source out and put the path directly into the cpp file.
    Qt Code:
    1. ...
    2. mSource = "qrc:/playlist.pls";
    3. if (mSource.isEmpty()){
    4. ...
    To copy to clipboard, switch view to plain text mode 
    Then the file could be opened but not read and I get the error message:
    Qt Code:
    1. [D] onError:58 - Unable to open the file
    2. [D] onCompleted:125 -
    To copy to clipboard, switch view to plain text mode 
    I spend nearly to days now to figure out what is wrong but I just cannot find anything on the web. Can someone help me please?

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

    Default Re: HowTo read playlist pls file

    As the error message says, "source" is a read-only property of the FileIO object. Fix the declaration of your FileIO class to allow writing the source property and you will be able to write to it. This has nothing to do with writing to the file itself (which you cannot do).

    Here is a full example:
    http://developer.nokia.com/community...g_files_in_QML

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

    Default Re: HowTo read playlist pls file

    Hi Chris,

    I was working with that example. But even after copying that example 1 to 1 I still get the error that the file cannot be opened. On my Mac I can open the file with TextEdit, so I do not think that it is corrupted. Any idea what I can do to find the error?

    Thanks!

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

    Default Re: HowTo read playlist pls file

    The first error message has nothing to do with being able to write to the file. It is complaining about not being able to write to the "source" property of the object.

    As for the other error message,
    Then the file could be opened but not read and I get the error message: ...
    This error message is output by the example's read() if the file cannot be opened. Chances are the path is wrong, or the resource file has not been built into your project.

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

    Default Re: HowTo read playlist pls file

    I have been using the file with other functions and there the it worked. So I am quite sure that my path is correct. Never the less I changed my approach and try to load the playlist directly using QMediaPlaylist.

Similar Threads

  1. Howto create custom File Browser view
    By f1ns in forum Qt Programming
    Replies: 3
    Last Post: 22nd February 2013, 16:15
  2. Read contents from the file using QHTTP Read()?
    By Gokulnathvc in forum Newbie
    Replies: 2
    Last Post: 21st June 2011, 08:03
  3. Replies: 1
    Last Post: 30th July 2010, 07:23
  4. is qt phonon can read realmedia file and divx file
    By fayssalqt in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2009, 15:42
  5. Replies: 1
    Last Post: 20th June 2008, 18:43

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.