Kodi Community Forum

Full Version: JSON-RCP support for FLAC + CUE sheet (No support or bug?)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been trying to load a FLAC + CUE sheet via JSON via two methods:

1) Loading a basic and smart playlists located in XBMC user's playlists folder. Both play well, displaying all the lay out of tracks within Music Library, however no success via JSON with regards to loading the cue sheet lay out.
2) Pointing the JSON API call directly to the audio file.

On both cases the FLAC audio file actually plays but just as 1 long track, since the cue sheet fails to load to provide the multiple tracks separation and information.

I'd greatly appreciate if anyone could point out whether this is a simple lack of support in XBMC JSON or something that actually should be working but it isn't due to a bug.

Obs.: I haven't tried any other format different than FLAC, although I presume the same behavior occurs for .mp3 and other formats.
You need to provide the JSON-RPC requests that you sent otherwise I'll have to get my crystal ball for an uneducated guess.
...and since we want the best guess, I will get back to you with the data this evening once I am back home. Thanks for helping out on this.
Hi Montellesse,

The code is using the following request for the repeat, however looking at the logs it seems the audio file is already playing without its cue sheet loaded:
Code:
JSONRPC: Incoming request: { "jsonrpc": "2.0", "method": "Player.SetRepeat", "params": {"playerid": 0, "repeat": "all" }, "id": 1 }

I went for direct play of file (without using playlists to make things more straightforward) and got 2 complete logs playing same file:

1) Direct Play from within XBMC Music Library (CUE sheet loads: multiple tracks lay out works and tracks are played individually) here – Line 521 aprox.
2) Direct Play via Python API (using TVTunes add-on) showing JSON (one long file plays only, no tracks lay out loaded; cue sheets seems unsupported) here – Line 600 aprox.

Audio file name in logs: Prokofiev - Glazunov Cinderella The Seasons (Disc 1).flac
FLAC + CUE files (.zip) can be accessed here if necessary.

As always, any help from your oracle is most appreciated. Thanks!
You need to post complete logs. Reason is that before the first snipped it would have been playing a musicdb:// URL and the fileitem in question would have contained the startoffset.
Thanks Jonathan. Complete logs are now included in previous post.
Yup - in the first case the cuesheet parsing has meant you have all tracks listed. You then started playing the first one.

In the second case, you're request the flac to be played. At this point, XBMC has no idea there's an accompanying .cue sheet.

The player doesn't know about the .cue sheet, rather it's determined when listing the folder. i.e. all the player gets is a bunch of "play this flac, starting at offset X and finishing at offset Y" items, where the .flac is identical each time, but the offsets change from song to song.

Note that if you scan said file into the library, then the individual tracks will be listed over the JSON-RPC API and will be able to be played back individually.
I absolutely follow what is going on now for the 2 examples given. However, how about when the FLAC ALbum is actually scanned into the library, as you mention:

1) Basic Playlist .m3u (here) containing the offset for just 2 tracks from a FLAC + CUE album previously scanned to the XBMC Music Library. The log shows that the file handled to the player is again the FLAC, whose path is extracted from the playlist in log line 615 aprox., and there is no listing of the two individual tracks via API. So even when the playlist contained just two tracks from the library which should be played individually, the whole FLAC for the album is being played instead without track lay out.

Log here and .m3u file content as follow:
Code:
#EXTM3U
#EXTINF:0,02. Prokofiev - Sergei Prokofiev. Cinderella, Op. 87, Act I: 2. Shawl dance
/Users/Cap/Music/CD17/Prokofiev - Glazunov   Cinderella   The Seasons (Disc 1).flac
#EXTINF:0,04. Prokofiev - Sergei Prokofiev. Cinderella, Op. 87, Act I: 4. The Father
/Users/Cap/Music/CD17/Prokofiev - Glazunov   Cinderella   The Seasons (Disc 1).flac

I am now clueless with regards to why the tracks aren't being listed and played as individual items according to playlist. Please let me know if any additional information is required.
The filenames in the m3u give no indication at all as to the appropriate offsets to use. I think you'll find if you just try and play that .m3u directly in XBMC you'll have the same problem, right?

If you construct a playlist using musicdb:// URLs it will work fine, however. i.e. construct using database id's - they're unique and contain the detail required to distinguish the tracks.

(Or alternately, just retrieve the song IDs you want to play over JSON-RPC and play using those song IDs?)
Thank you Jonathan, this is incredibly helpful.

I will do some work on building and testing playlists via the methods described on your 2nd paragraph.

I tried, as you said, playing the .m3u directly within XBMC and I got some unexpected results:

1) I created a .m3u basic playlist via XBMC GUI playlist editor and saved it. When one is creating the playlist choosing tracks from the FLAC + CUE album (previously scanned to library), one can see the different individual tracks being added and listed. After saving the playlist, they are no longer there and instead, only the 1st track of the album is listed as many times as tracks were saved to the playlist. Of course trying to play this .m3u results in just the 1st track of the album being played. When one opens the .m3u with an xml editor, it is possible to see the different tracks listed, however and again, no offset whatsoever specifying when each track should kick in, even when this playlist was created by XBMC. If one plays it via Python API, then the whole album plays as one long track, just as described in previous post, the reasons for which you explained well. Log here

2) If a Smart Playlist is created with a rule to gather a minimum number of tracks (10 in this case) from the mentioned FLAC + CUE album, then we succeed and these tracks are listed and individually played by XBMC on the GUI, if the smart playlist is played directly from within the music library. Log here

Here I'd like to ask:
a) Do you think issue 1) could be attributed to a possible instability on the Alpha 11 that is currently being worked on or should I just file the bug report for this issue on creating and playing .m3u playlists from FLAC + CUE music albums?

b) Even though when the smart playlist lists and plays all the tracks determined by its rules when it is loaded directly from within XBMC, it still doesn't when loaded via Python API, thus a way to call it and load its tracks successfully is still needed. Since a smart playlist works with a criteria, how could I go about using the same methods suggested by you (musicdb:// URLs, database ID's, or retrieve the songs ID's via JSON-RPC to play the tracks)?

Jav
a. Nope - it will have always been like that. I don't know if M3U playlists have the ability to specify the offsets. If they don't, we probably shouldn't be extending them.

b. I'm not sure how the JSON-RPC setup for playlists works, and whether you can add based on database ID or whatever. But I would have thought that if you have a previously saved smartplaylist that you should be able to request that it plays via the python API the same way you can for another playlist?
(2013-12-22, 01:25)jmarshall Wrote: [ -> ]b. I'm not sure how the JSON-RPC setup for playlists works, and whether you can add based on database ID or whatever. But I would have thought that if you have a previously saved smartplaylist that you should be able to request that it plays via the python API the same way you can for another playlist?

as i've read some where on the forum smartplaylists don't work in the Python Play API like a normal playlist
(2013-12-22, 01:27)Martijn Wrote: [ -> ]
(2013-12-22, 01:25)jmarshall Wrote: [ -> ]b. I'm not sure how the JSON-RPC setup for playlists works, and whether you can add based on database ID or whatever. But I would have thought that if you have a previously saved smartplaylist that you should be able to request that it plays via the python API the same way you can for another playlist?

as i've read some where on the forum smartplaylists don't work in the Python Play API like a normal playlist

Yes, that is correct (as I understand it) - you cannot load a smartplaylist via the python api (I tried- then switched to JSON after some-one helped via another post when I asked the question about smartplaylist support).

The TvTunes Perspective
(As I believe this may be the origin of the original question)

TvTunes has "very basic" playlist support. This includes both standard-playlist (i.e. m3u) and smartplaylists. However TvTunes does not play the playlist "as-is", instead it reads the files out of the playlist and constructs it's own internal playlist. This is for 2 reasons:

1) There may be multiple playlists, or additional tracks to add the the playlist (So need to consolidate them)
2) You can not use the python api to play a smartplaylist

I look at the ability to specify a playlist file in a tvtunes.nfo file as a "shortcut" to get the file-list - rather than having to specify each file in turn within your playlist. (It also allows for the case where you move the audio tracks - then you only need to update the playlist - not the tvtune.nfo as well).

For the CUE file support, we would need a way via the Python API to add an item to a playlist and specify a "start point" and "end point" when we add the file. And hence the need for PlayListItem to support a "setStartTime" and "setEndTime" option. In addition it would also need a way to retrieve the start and stop time from the playlists.

For this reason, TvTunes does not support CUE files (and it is not in the listed files that are supported) - I do not think it is sensible for TvTunes to try and start and stop tracks at various points based on a CUE file (which it would need to parse itself). I don't see this as a big deal - if you have a "soundtrack album" - then getting the whole file played when on a given movie/tv show isn't too bad a thing.

I hope this helps clarify.

Rob


Side note: Couldn't see PlayListItem in the Gotham API Documentation
Ironically and thankfully, a basic .m3u playlist played via TvTunes will play the whole album (since the CUE sheet can't be parsed), and as Rob says, it doesn't represent any substantial difference, as long as there aren't more albums we wanted shuffled in that playlist. At the end, music theme snippets from different parts of the album will be played everytime one moves to that movie in TVTunes. The purpose is met indeed.

The true limitation, as seen through this thread, comes at the core of XBMC for those regular users of the music library in XBMC who have built or will build basic playlists including tracks from albums with CUE sheets: their playlists will simply and only play the 1st track of each one of these albums. Smart playlists however, and for reasons unknown to me, stand victorious at handling FLAC + CUE sheets within XBMC direct music play, and currently represents the only valid workaround for those who need to create playlists with CUE sheet albums (audiophiles with a considerable number of live set recordings, usually in the form FLAC + CUE, might be an example). Now, with some ingenious approach at setting the rules in a smart playlist, users may be able to achieve almost all of their playlist needs which normally would be covered by basic playlists.

I believe this handling limitation should be stated somewhere in the wiki, for both via direct play within XBMC and JSON Python API, which could give users a tested straightforward yes-and-no list of supported capabilities regarding CUE sheets when compared to other audio formats.
One thing that could be done is look at the specifications for .m3u files and see whether a "modification" could be done to specify the startoffsets in there. If that can be done, you'd be away.

Regarding TVTunes constructing it's own playlist, this will be fine as long as it uses the listitems from the smartplaylist - i.e. when constructing the playlist construct it using listitem's with appropriate startOffset/endOffset set. That's the missing ingredient. i.e. if it constructs a .m3u file then that won't work as you lose the start/end offset. If it constructs the playlist and passes that directly (can the python API do this?) then it will work fine.

Cheers,
Jonathan