Error: Cannot assign [undefined] to QUrl
-
Almost :-)
for (var j=0; j<items.count;j++){ console.log("item:"+ items.get(index,"filePath")) }
Maybe that will help us pinpoint the issue.
-
Almost :-)
for (var j=0; j<items.count;j++){ console.log("item:"+ items.get(index,"filePath")) }
Maybe that will help us pinpoint the issue.
@sierdzio Hi, i tried printing those items, but i am getting the same error again (Error: Cannot assign [undefined] to QUrl), also when i try to print those items, i am not able to find the auto get method for items(i.e items.get() method) and it is not entering the for loop.
what can be the possible solution? thanks -
Please try:
- print items.count and items.get(0, "filePath")
- rewrite items to be a normal QML component and not a property (see example code in the docs) and see if it works
- make sure the path is OK :-)
print items.count and items.get(0, "filePath")
output:
qml: items count >> 0
qml: items at 0 position >> undefinedrewrite items to be a normal QML component and not a property (see example code in the docs) and see if it works
i made the following changes, pls rectify if there is any mistake
FolderListModel{ id: items folder: "/home/ubuntu/Documents/Sample_Examples_Qt_Qml/DummyMusicPlayer/Songs" nameFilters: ["*.mp3"] }
after making changes i am getting the following output:
qml: Entered init function
qml: calling index function
qml: entered setindex function
qml: else part
qml: items count >> 0
qml: items at 0 position >> undefined
qrc:/main.qml:58: Error: Cannot assign [undefined] to QUrl -
OK, so now at least we know this:
- issue is not related to QtMultimedia
- issue is with FolderListModel
- "Cannot assign [undefined]" is there, because items is empty (no .mp3 files are detected in Songs folder)
Try using URL instead of path:
folder: "file:///home/ubuntu/Documents/Sample_Examples_Qt_Qml/DummyMusicPlayer/Songs"
Relative and absolute paths should work, but apparently something fails here. Also, of course, please make sure there are some MP3s in that dir.
-
OK, so now at least we know this:
- issue is not related to QtMultimedia
- issue is with FolderListModel
- "Cannot assign [undefined]" is there, because items is empty (no .mp3 files are detected in Songs folder)
Try using URL instead of path:
folder: "file:///home/ubuntu/Documents/Sample_Examples_Qt_Qml/DummyMusicPlayer/Songs"
Relative and absolute paths should work, but apparently something fails here. Also, of course, please make sure there are some MP3s in that dir.
@sierdzio yup, now its detecting the mp3 files, i am getting the following output,
qml: Entered init function
qml: calling index function
qml: entered setindex function
qml: else part
qml: items count >> 5
qml: items at 0>> /home/ubuntu/Documents/Sample_Examples_Qt_Qml/DummyMusicPlayer/Songs/Cinema_Choopista-StarMusiQ.Com.mp3
qml: before playing the songBut i am not sure the song is playing or not, because i am not getting sound. Does it require anything else for this?
-
@sierdzio yup, now its detecting the mp3 files, i am getting the following output,
qml: Entered init function
qml: calling index function
qml: entered setindex function
qml: else part
qml: items count >> 5
qml: items at 0>> /home/ubuntu/Documents/Sample_Examples_Qt_Qml/DummyMusicPlayer/Songs/Cinema_Choopista-StarMusiQ.Com.mp3
qml: before playing the songBut i am not sure the song is playing or not, because i am not getting sound. Does it require anything else for this?
Nice, I'm glad to hear that problem is solved.
@Naveen_D said in Error: Cannot assign [undefined] to QUrl:
But i am not sure the song is playing or not, because i am not getting sound. Does it require anything else for this?
I'm not familiar with QtMultimedia, I can't help here unfortunately. My first guesses are:
- check if you have gstreamer 0.1 installed
- check if you have mp3 codecs installed (mp3lame or something)
- check some QtMultimedia examples in Qt Creator - does the sound work there?
-
Nice, I'm glad to hear that problem is solved.
@Naveen_D said in Error: Cannot assign [undefined] to QUrl:
But i am not sure the song is playing or not, because i am not getting sound. Does it require anything else for this?
I'm not familiar with QtMultimedia, I can't help here unfortunately. My first guesses are:
- check if you have gstreamer 0.1 installed
- check if you have mp3 codecs installed (mp3lame or something)
- check some QtMultimedia examples in Qt Creator - does the sound work there?
Thanks for the information,
But previously i had tried to play songs using this and it was working fine, i found out that when i directly give source in the media player and play it is working fine the song is playing, but when i give the folderlistmodel path using the get method it is not working.
also i tried to print the path, when i give the direct source path, the path printed is the URL path but when it takes through the folderlistmodel, it is the normal pathi.e Direct source path with song if i give, the path set is :
"file:///home/ubuntu/Documents/Sample_Examples_Qt_Qml/DummyMusicPlayer/Songs/David Guetta - Love Don't Let Me Go (Memorax Remix) [FREE].mp3"and through folderlistmodel with the index, the path set is :
"/home/ubuntu/Documents/Sample_Examples_Qt_Qml/DummyMusicPlayer/Songs/David Guetta - Love Don't Let Me Go (Memorax Remix) [FREE].mp3"Can anyone please suggest the possible solution.
Thanks -
Cool, good to hear that :) Please mark the topic as solved, too.