Quantcast
Channel: Kodi Community Forum - All Forums
Viewing all articles
Browse latest Browse all 84005

JSON - Playing a song by ID

$
0
0
Good day !

I know this might sound really simple, but for some reason it simply doesn't work :/ I've built an app that searches for songs and returns a list of them, then I'd like to be able to either queue or play a song by sending back the ID of the song. Sounds straight-forward. I'm using the .net wrapper (XbmcJson) which turns commands to/from json, so here's what the code looks like in there:

Code:
public void Add(string file, int? songId, int? artistId, int? albumId)
        {
            var args = new JObject();

            if (file != null)
                args.Add(new JProperty("file", file));
            if (songId != null)
                args.Add(new JProperty("songid", songId));
            if (artistId != null)
                args.Add(new JProperty("artistid", artistId));
            if (albumId != null)
                args.Add(new JProperty("albumid", albumId));

            Client.Invoke("AudioPlaylist.Add", args);
        }

So I simply pass in "null, {id}, null, null", which means it'll send out a command to add the track to the playlist. I first clear the playlist, then add the track, then hit play as there didn't seem to be a "play" method in the wrapper api I'm using (I've already changed a bunch of things in it, so if there's a better way I don't mind adding the code).

Anybody know why that wouldn't work ? I've also tried sending in the file path (although that's kind of an ugly solution I'd like to avoid because the client doesn't have the full path, and when the ID gets sent it, I then have to re-query for the path, too many roundtrips).

Thanks,
Eric.

Viewing all articles
Browse latest Browse all 84005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>