From: <kro...@us...> - 2010-12-08 17:25:28
|
Revision: 4022 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4022&view=rev Author: kroko_koenig Date: 2010-12-08 17:25:21 +0000 (Wed, 08 Dec 2010) Log Message: ----------- add playlist support Modified Paths: -------------- trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs trunk/plugins/AndroidRemote/Server/AndroidRemote.suo Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-12-08 15:08:48 UTC (rev 4021) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-12-08 17:25:21 UTC (rev 4022) @@ -40,6 +40,7 @@ using MediaPortal.Util; using MediaPortal.Database; using MediaPortal.Configuration; +using MediaPortal.TagReader; using MediaPortal.Player; using MediaPortal.Playlists; @@ -358,18 +359,6 @@ data.Add(child.Name, child.InnerText); } - //PlayListPlayer playlistPlayer = PlayListPlayer.SingletonPlayer; - //PlayList playList = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC); - - //PlayListItem playlistItem = new PlayListItem(); - //playlistItem.Type = PlayListItem.PlayListItemType.Audio; - //playlistItem.FileName = "c:\\mp3\\the-gossip-heavy-cross-full-length-hq--lyrics.mp3"; - //playlistItem.Description = "My Desc"; - //playlistItem.Duration = 1234; - - //playlistItem.MusicTag = null; - //playList.Add(playlistItem); - if (data.ContainsKey("command")) { @@ -526,6 +515,73 @@ GUIGraphicsContext.OnAction(action); } #endregion + + #region playlist + if (data["command"] == ("ADD_MUSIC")) + { + // add music + // parameter = filename,artist,title,duration + + PlayListPlayer playlistPlayer = PlayListPlayer.SingletonPlayer; + PlayList playList = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC); + + bool found = false; + string fileName = data["filename"]; // TODO need to be converted to local name + + foreach (PlayListItem item in playList) + { + if (item.FileName == fileName) + { + found = true; + break; + } + } + + if (!found) + { + PlayListItem playlistItem = new PlayListItem(); + playlistItem.Type = PlayListItem.PlayListItemType.Audio; + playlistItem.FileName = fileName; + playlistItem.Description = data["artist"] + " - " + data["title"]; + playlistItem.Duration = 0; + + MusicTag tag = new MusicTag(); + tag.Artist = data["artist"]; + tag.Title = data["title"]; + + tag.Duration = Convert.ToInt32(data["duration"]); + tag.FileName = fileName; + + playlistItem.MusicTag = tag; + playList.Add(playlistItem); + } + + } + + if (data["command"] == ("REMOVE_PLAYLIST")) + { + // add music + // parameter = filename + + PlayListPlayer playlistPlayer = PlayListPlayer.SingletonPlayer; + PlayList playList = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC); + + string fileName = data["filename"]; // TODO need to be converted to local name + playList.Remove(fileName); + } + + if (data["command"] == ("CLEAR_PLAYLIST")) + { + // clear playlist + // parameter = none + + PlayListPlayer playlistPlayer = PlayListPlayer.SingletonPlayer; + PlayList playList = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC); + + playList.Clear(); + } + + #endregion } } } @@ -1313,7 +1369,7 @@ msg += "<CurrentItem>" + currentSong.ToString() + "</CurrentItem>\r\n"; msg += "<TotalItem>" + list.Count.ToString() + "</TotalItem>\r\n"; - foreach (MediaPortal.Playlists.PlayListItem item in list) + foreach (PlayListItem item in list) { string desc = item.Description; int duration = item.Duration; @@ -1393,7 +1449,7 @@ if (Directory.Exists(key)) { string[] files = Directory.GetFiles(key, "*.jpg", SearchOption.AllDirectories); - foreach(string f in files) + foreach (string f in files) { allPicturesList.Add(f); } Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |