How to use QML Playlist Type save function to save playlist.
Solved
QML and Qt Quick
-
I am unable to use Playlist save function to save playlist of my Music Player made in QML.
I already have tried using the function, but the operation always fails.FileDialog { id: filesLoader title: "Chose files to add to playlist" folder: shortcuts.music selectMultiple: true selectExisting: true nameFilters: ["Mp3 Files (*.mp3)"] onAccepted: { audioPlaylist.addItems(fileUrls) if(audioPlaylist.save("file:///E:/Playlist")) { console.log("Playlist Saved") } else { console.log("Playlist Save Failed"+audioPlaylist.errorString) } } }
I dont know why. May be because of providing wrong location parameter in the syntax
bool Playlist.save (location,format)
Syntax Link
I checked the documentation of Playlist Type but it does not mention any guidelines about how and what type the location is required.
I can use FolderListModel, but I want to explore Playlist Type if useful.
Please help me. -
@iamRahul I figured it out. We need to specify full location path till the file, and specify file type in format. Then it worked for me.
if(audioPlaylist.save("file:///C:/MyMusicPlayer/Playlists/global_playlist.m3u","m3u")) { console.log("Playlist Saved") }
Adding the filename global_playlist.m3u and format m3u made it working for me.