Exemple #1
0
 public bool DeleteSongFromPlayList(string playlistName, LibraryItem song)
 {
     PlexServer.DeleteSongFromPlaylist(song, playlistName, Name);
     return(true);
 }
Exemple #2
0
        /*public void Stop()
         * {
         *  Dispatch("stop");
         *  progress.Stop();
         *  progressCnt = 0;
         *
         *  Playing(false);
         * }*/

        private void Play(LibraryItem item)
        {
            Dispatch(item.Key, 0, item.Type);
        }
Exemple #3
0
 public bool AddSongToPlayList(string playlistName, LibraryItem song)
 {
     PlexServer.AddSongToPlaylist(song.Key, playlistName, Name);
     return(true);
 }
Exemple #4
0
        void server_OnHttpRequest(object sender, OnHttpRequestArgs e)
        {
            try
            {
                if (e.Request.HasContentLength && e.Request.Path == "/:/timeline")
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(e.Request.ContentString);
                    XmlNodeList timelineList = doc.SelectNodes("MediaContainer/Timeline");

                    var currentType = "music";

                    foreach (XmlNode item in timelineList)
                    {
                        var type = item.Attributes["type"].Value;


                        if (item.Attributes["state"].Value == "playing")
                        {
                            foreach (var sectionItem in section)
                            {
                                var currentItem = currentlyPlaying;

                                if (sectionItem.Key == item.Attributes["key"].Value)
                                {
                                    currentlyPlaying = sectionItem;
                                    if (Currentlyplaying.Type == "movie" || Currentlyplaying.Type == "episode")
                                    {
                                        currentType = "video";
                                    }
                                    else if (Currentlyplaying.Type == "track")
                                    {
                                        currentType = "music";
                                    }

                                    if (!isPlaying || currentItem != currentlyPlaying)
                                    {
                                        isPlaying = true;
                                        Playing(true, "playing", Name);
                                    }
                                    break;
                                }
                            }
                        }
                        if (type == currentType)
                        {
                            if (item.Attributes["time"] != null)
                            {
                                PlayProgress(this, new PlayProgressEventArgs(Convert.ToInt64(item.Attributes["time"].Value) / 1000, Name));
                            }

                            if (item.Attributes["state"].Value == "paused")
                            {
                                isPlaying = false;
                                Playing(false, "paused", Name);
                            }
                            else if (item.Attributes["state"].Value == "stopped")
                            {
                                if (isPlaying)
                                {
                                    if (isPlayAll && section.Count > section.IndexOf(currentlyPlaying) + 1)
                                    {
                                        playNextItem = new CTimer(PlayNextItemCallback, this, 5000);
                                    }
                                    else if (isRepeatAll)
                                    {
                                        SelectItem(CurrentSection[0]);
                                    }
                                    else
                                    {
                                        isPlayAll = false;
                                    }

                                    isPlaying = false;
                                    PlayProgress(this, new PlayProgressEventArgs(Convert.ToInt64(currentlyPlaying.Duration) / 1000, Name));
                                    Playing(false, "stopped", Name);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }