We have moved to a new Sailfish OS Forum. Please start new discussions there.
2

use playlist in app

asked 2014-08-15 10:57:02 +0300

FloR707 gravatar image

Hi there!

I would like to use music in my new app. The plan was that the user can choose one of its playlists and the the songs from that list should be played in the background. Does anyone have an idea how this could work or at least where I could get help figuring that out.

Thanks

edit retag flag offensive close delete

Comments

The playlists created with Jolla's media app are situated in /home/nemo/Music/playlists/ if you were looking for that.

nthn ( 2014-08-15 15:19:15 +0300 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2014-08-15 19:06:34 +0300

r0kk3rz gravatar image

updated 2014-08-15 19:11:25 +0300

http://sailfishwayfarer.blogspot.co.uk/2014/08/qt5sparql-and-tracker.html

search tracker for playlists on the phone, that example is in QML but you can access it from the C++ side as well.

then use a QMediaPlayer to handle the music playback from the C++ side or a MediaPlayer from the QML side

edit flag offensive delete publish link more

Comments

Thanks a lot! I guess that is exactly what I need. Too bad that I am still a beginner and most things sound rather french to me.

FloR707 ( 2014-08-16 10:19:00 +0300 )edit

That's my blog, and i'm fairly new to this game as well so I can probably help you out.

Best way I've found is to use the tracker-sparql command on the jolla shell to refine your SPARQL query to what you want, you can also point tracker-info to a file to see what kind of tags it puts on things.

the QMediaPlayer stuff is really really easy to get going so I didn't bother writing up a blog post about it

r0kk3rz ( 2014-08-16 19:31:01 +0300 )edit

Currently I am trying to work backwards. Implementing the MediaPlayer was really easy but I am stuck with reading the pls file. I cannot read it. Here is a post where I asked for help. When I manage to read the file the next step would be to get the urls into an array(?), then pass the array to the MediaPlayer. When this works the next step would be the search tracker. But currently I do not have a lot of hope to get this done. Maybe you are also new to Sailfish but you definitely have some experience with c++ or so. I looked at you music player app. I would not even dream about trying something like that.

FloR707 ( 2014-08-17 21:42:31 +0300 )edit

You could do it that way, but I think the QMediaPlaylist is going to be what you need.

Its got a load() method where you can give it a url, which hopefully reads in your playlist, then you feed the QMediaPlaylist object into the QMediaPlayer source for playback.

r0kk3rz ( 2014-08-17 22:08:06 +0300 )edit

Thanks for the hints! I managed to create a c++ class that is accessible from QML to start and stop the player. It also loads a playlist but so far only m3u and not the pls from the Music folder =( I hope I find a way around that.

FloR707 ( 2014-08-19 14:14:07 +0300 )edit
0

answered 2014-08-31 12:48:04 +0300

FloR707 gravatar image

updated 2014-08-31 13:12:57 +0300

I found a way to read the .pls files. Currently I am reading the file with C++ and extract the URLs to the files. These URLs I add to a QMediaPlaylist. This works very nicely so far. Here is my code. Maybe someone someone can improve it a little =)

Okay, posing code is not really possible here. So take a look here at the code.

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
1 follower

Stats

Asked: 2014-08-15 10:57:02 +0300

Seen: 449 times

Last updated: Aug 31 '14