Any way to programmatically play a playlist? Command line, WiFi Remote, MPExtended? (1 Viewer)

mrceolla

Portal Pro
December 11, 2010
136
12
Country flag
Hello,

I'm looking to integrate MediaPortal into my home automation system and am hoping for a way to programmatically do things. I can already send IR commands for simple things like Play, Stop, Next, Prev, but I would like a way to be able to play a particular playlist without having to build complicated IR macros to navigate the UI, hoping nothing changes to break it.

Is there any way to programmatically tell MediaPortal to play a particular file or playlist?

My home automation system (HomeSeer 3) is running on the same box as MediaPortal, so I could run command line stuff if that's a possibility.

Or, does WiFi Remote or MPExtended support this type of thing?

Thanks for any input!
 

johanj

MP Donator
  • Premium Supporter
  • January 31, 2009
    781
    398
    42
    Sweden Sweden
    WifiRemote and MPExtended both handle playlists in a complementary way. The later only handle the in MP loaded playlist. With MPExt. you can read and modify all playlists. But it's only WifiRemote that can play/stop/next/previous on the current playlist.

    For WifiRemote you need a tcp/ip connection. For MPExt. you send http requests.
    http://wiki.team-mediaportal.com/1_MEDIAPORTAL_1/17_Extensions/3_Plugins/WifiRemote/Commands
    http://wiki.team-mediaportal.com/1_...s/MPExtended/Developers/API_Documentation/MAS
     

    mrceolla

    Portal Pro
    December 11, 2010
    136
    12
    Country flag
    Thank you for the reply. Sorry for my delay. For some reason I didn't see an email notification of the reply.

    So, are you saying that MPExtended is able to load a playlist, but I'll need to use WifiRemote or a real IR command to play it once it's loaded?

    I've located the documentation for each of those items already, but I'm having difficulty figuring out exactly how to use them. For example, how do I send parameters to an end point in MPExtended, and how do I know what those parameters should be? Example, I run this in a browser:

    http://IPAddress:4322/MPExtended/MediaAccessService/json/GetPlaylists?provider=1

    That doesn't work. I get an error displayed in Firefox. How do I find out what the provider value should be and how do I send that?

    If I want to do /json/AddPlaylistItem, how do I find out the possible values for the following:

    provider (nullable int)
    playlistId (string)
    type (WebMediaType)
    id (string)
    position (nullable int)

    Does MPExtended use GET, POST, both, something else?

    I'm having trouble finding examples to work from. Any you could point me to?

    Much thanks!
     

    mrceolla

    Portal Pro
    December 11, 2010
    136
    12
    Country flag
    bump. I can't seem to figure this out. Any further guidance would be greatly appreciated.
     

    johanj

    MP Donator
  • Premium Supporter
  • January 31, 2009
    781
    398
    42
    Sweden Sweden
    Your request should work if you change to provider 4. List of providers is found in the wiki;)
    http://wiki.team-mediaportal.com/1_...te_Access/MPExtended/Developers/MAS_providers

    You will need to know the id of the track or album in order to add them to a playlist. This can be retrieved by other MAS call. Example of usage of both MPExt. and WifiRemote.

    self.addTrackToPlaylist = function() {
    CF.getJoin("l" + Joins.music.lstTracks + ":" + self.currentTrackIndex + ":" + "d1", function(j, v, t) {
    var id = t["[trackId]"];
    var params = "provider=4" + "&id=" + encodeURIComponent(id);
    Controller.getActiveClient().rpc(self, "MediaAccessService", "GetMusicTrackBasicById", params, function(data) {
    var params2 = "provider=4&playlistId=" + self.playlists[self.selectedPlaylistIndex].Id + "&type=1&id=" + encodeURIComponent(id)// + "&position=" +(self.playlistTracksArrayMPE.length-1);
    Controller.getActiveClient().rpc(self, "MediaAccessService", "AddPlaylistItem", params2, function(success) {
    if (success) {
    self.Log("Track added to playlist")
    var dataArray = [];
    dataArray.push(data);
    self.addItemsToPlaylists(dataArray);
    } else {
    self.Log("Track failed to be added to playlist")
    }
    });
    });
    });
    };

    self.addTrackToLoadedPlaylist = function() {
    CF.getJoin("l" + Joins.music.lstTracks + ":" + self.currentTrackIndex + ":" + "d1", function(j, v, t) {
    var id = t["[trackId]"];
    var params = "provider=4" + "&type=1&id=" + encodeURIComponent(id);
    Controller.getActiveClient().rpc(self, "MediaAccessService", "GetExternalMediaInfo", params, function(playInfo) {
    WifiRemote.enqueueMusicTrack(id, playInfo);
    WifiRemote.retrieveMusicPlaylist();
    });
    });
    };

    self.addAlbumToLoadedPlaylist = function() {
    CF.getJoin("l" + Joins.music.lstAlbums + ":" + self.currentAlbumIndex + ":" + "d1", function(j, v, t) {
    var id = t["[id]"];
    var params = "provider=4" + "&type=7&id=" + encodeURIComponent(id);
    Controller.getActiveClient().rpc(self, "MediaAccessService", "GetExternalMediaInfo", params, function(playInfo) {
    WifiRemote.enqueueMusicAlbum(id, playInfo);
    WifiRemote.retrieveMusicPlaylist();
    });
    });
    };
     

    mrceolla

    Portal Pro
    December 11, 2010
    136
    12
    Country flag
    Thank you for your reply. I did find how to list the available providers. I am now typing this URL into Firefox:

    http://ipaddress:4322/MPExtended/MediaAccessService/json/GetPlaylists?provider=4

    and receive the following error:

    {"ExceptionType":"System.Collections.Generic.KeyNotFoundException","Message":"The given key was not present in the dictionary.","StackTrace":" at System.Collections.Generic.Dictionary`2.get_Item(TKey key)\u000d\u000a at MPExtended.PlugIns.MAS.MPMusic.MPMusic.GetPlaylists() in C:\\Users\\Oxan\\Documents\\Projects\\MPExtended\\PlugIns\\MPExtended.PlugIns.MAS.MPMusic\\MPMusic.cs:line 504\u000d\u000a at MPExtended.Services.MediaAccessService.MediaAccessService.GetPlaylists(Nullable`1 provider) in C:\\Users\\Oxan\\Documents\\Projects\\MPExtended\\Services\\MPExtended.Services.MediaAccessService\\MediaAccessService.cs:line 820\u000d\u000a at SyncInvokeGetPlaylists(Object , Object[] , Object[] )\u000d\u000a at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)\u000d\u000a at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)"}

    Any idea why I am getting this error?

    I am trying to use this command to get the IDs of my playlists since I don't know what they are. I'm hoping once I have that information that I'll be able to load this playlist via MPExtended or WiFi remote. Is this possible? I can trigger play via IR if needed so I'm not worried about that right now. I'm just trying to programmatically load a playlist.

    Are simple HTTP GET commands enough to accomplish this or will I need to write my own application? I'm trying to interface HomeSeer 3 with MediaPortal for a few simple tasks, such as this one. I can run VB.NET, vbScript and Perl within HomeSeer if needed.
     

    johanj

    MP Donator
  • Premium Supporter
  • January 31, 2009
    781
    398
    42
    Sweden Sweden
    I tried the url you posted in chrome(replacing the ip to my local), then one get a popup with user/password if these are configured in MPExt. This is the reply:
    [{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"QmViZWwubTN1","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Bebel.m3u"],"Title":"Bebel.m3u","Type":11,"ItemCount":18},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"QmV5b25jZS5tM3U=","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Beyonce.m3u"],"Title":"Beyonce.m3u","Type":11,"ItemCount":10},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"Q2FmZSBkZWwgbWFyLm0zdQ==","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Cafe del mar.m3u"],"Title":"Cafe del mar.m3u","Type":11,"ItemCount":30},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"Q2hyaXN0aWFuIEtqZWxsdmFuZGVyLm0zdQ==","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Christian Kjellvander.m3u"],"Title":"Christian Kjellvander.m3u","Type":11,"ItemCount":25},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"Q291bnRpbmcgQ3Jvdy5tM3U=","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Counting Crow.m3u"],"Title":"Counting Crow.m3u","Type":11,"ItemCount":10},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"Q3JlZWQubTN1","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Creed.m3u"],"Title":"Creed.m3u","Type":11,"ItemCount":12},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"RGFtaWVuIFJpY2UubTN1","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Damien Rice.m3u"],"Title":"Damien Rice.m3u","Type":11,"ItemCount":11},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"ZGVmYXVsdC5tM3U=","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\default.m3u"],"Title":"default.m3u","Type":11,"ItemCount":1},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"RGlzdHVyYmVkLm0zdQ==","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Disturbed.m3u"],"Title":"Disturbed.m3u","Type":11,"ItemCount":24},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"SmFtZXMgQmx1bnQubTN1","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\James Blunt.m3u"],"Title":"James Blunt.m3u","Type":11,"ItemCount":33},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"S2VudC5tM3U=","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Kent.m3u"],"Title":"Kent.m3u","Type":11,"ItemCount":41},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"TmljayBDYXZlLm0zdQ==","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Nick Cave.m3u"],"Title":"Nick Cave.m3u","Type":11,"ItemCount":11},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"U3RpbmcubTN1","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Sting.m3u"],"Title":"Sting.m3u","Type":11,"ItemCount":23},{"PID":4,"Artwork":[],"DateAdded":"\/Date(-3600000+0100)\/","Id":"VGVzdC5tM3U=","Path":["C:\\Users\\Johan\\Documents\\My Playlists\\Test.m3u"],"Title":"Test.m3u","Type":11,"ItemCount":12}]

    Yes, it's simple HTTP get requests that can be tested in a browser.

    Yes, you can load the playlists in WifiRemote and also skip songs there.

    I guess something is not configured correctly in MPExt. Check the database location in the MPExt. configurator. I don't remember if one need to do something special with playlist path.
     

    mrceolla

    Portal Pro
    December 11, 2010
    136
    12
    Country flag
    Thank you for your continued help. I am getting a response with /MPExtended/MediaAccessService/json/GetMusicAlbumsBasic?provider=4 so it appears I am able to access the music database. My music and playlists are on a network drive. Could that be the cause of my problems? I am able to navigate my music shares via aMPdroid when I use VNC paths. Of course I don't see any way to access playlists via aMPdroid as my playlists are outside of my main music share, but when I go to the Playlists option in MP music menu I can see the playlists in my playlist folder.

    Any other ideas on how to solve this problem or an alternative way to accomplish my goal? I just want to be able to programmatically start playing a playlist. If I have the full path to the playlist file, is there a simple command that I can issue to play that file?
     

    johanj

    MP Donator
  • Premium Supporter
  • January 31, 2009
    781
    398
    42
    Sweden Sweden
    In general one avoid issues by running MPExtended service as a Windows admin account. This use should have access to the network shares.

    But for starting a playlist you only need WifiRemote, Check the playlist section:
    http://wiki.team-mediaportal.com/1_MEDIAPORTAL_1/17_Extensions/3_Plugins/WifiRemote/Commands

    You can do all things(load, edit,play,stop, skip, add songs) with a playlist using WifiRemote for the active playlist in MediaPortal. But you can only edit the currently loaded playlist using WifiRemote. With MPExtended it's possible to edit all playlists and not only the active one. But playback control is only WifiRemote.
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    joecrow [solved] DVD won't play properly. General Support 3
    M.Hulot MP plays in Internal Blu-ray-Player-mode always first audio stream not the one I chosen in settings General Support 1
    BrownGhost Mepo/MediaInfo takes 59 secunds to open library and start play :o( General Support 26
    I 1.25.0 Videos in HEVC UHD 2160p don't play good watch/edit Videos 8
    CanadianEh MP TV server rebuild with Colossus 2 - Kodi clients receive PMT error when playing videos recoreded by Colossus 2 TV-Server 1
    M [solved] WTV Files does not play on client, MPEG files works well General 1
    A [solved] How to Play All Videos in a List watch/edit Videos 3
    horned_reaper [solved] When playing music Fanart does not shuffle Fanart Handler 20
    horned_reaper [solved] No Fanart when playing Fanart Handler 115
    horned_reaper [solved] When playing music Fanart does not appear immediately after downloading Fanart Handler 272
    B MP 2.2.3 Error playing videos from NAS Submit: Bug Reports 2
    N Play a TV recording needs a double selection - twice ok on remote Television (MyTV frontend and TV-Server) 2
    M MP 2.2.3 Unable to play .ts recordings and MediaPortal stops working for TV viewing General 31
    Z Error when attempting to play Blu Ray General 1
    Rob Hexenmeister Playing with hyperlinkParameter and List Control indexes General Support 2
    C Problem playing videos created on IPhone X and Samsung S9 General Support 2
    2BitSculptor MP 1.23.. music stops playing General Support 6
    C Attempt to play DVD locks up MediaPortal watch/edit Videos 0
    H Unable to play stream - again... Television (MyTV frontend and TV-Server) 2
    B Suddenly MP is unable to play anything Watch / Listen Media 6
    Edwardfc [solved] Mp 2.2.1 Configuration Issues - Goes to Sleep while playing Music General 6
    M After a while Live TV or Recorded TV doesn't play first time General Support 9
    L [solved] MP2 doesnt play anything - player missing? General 1
    badboyxx MP 1.22 final is crashing when jumping forward while playing DVD-Iso watch/edit Videos 26
    S [solved] Live TV playing stopped General 13
    Similar threads

























    Top Bottom