コード例 #1
0
        /// <summary>
        /// Handle an MPTvSeries message received from a client
        /// </summary>
        /// <param name="message">Message</param>
        /// <param name="socketServer">Socket server</param>
        /// <param name="sender">Sender</param>
        internal static void HandleTvSeriesMessage(Newtonsoft.Json.Linq.JObject message, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            string action = (string)message["Action"];

            if (!string.IsNullOrEmpty(action))
            {
                // A series id is needed for the following actions.
                // If a series id was supplied we use this, otherwise we
                // try to get an id by the series name.
                //
                // If this isn't successful we do nothing.
                int?   seriesId   = (int?)message["SeriesId"];
                string seriesName = (string)message["SeriesName"];
                bool   resume     = (message["AskToResume"] != null) ? (bool)message["AskToResume"] : true;

                // Get series id by show name if no id supplied
                if (seriesId == null && !string.IsNullOrEmpty(seriesName))
                {
                    seriesId = TVSeriesHelper.GetSeriesIdByName(seriesName);
                }

                if (seriesId != null)
                {
                    // Play specific episode of series
                    if (action == "playepisode")
                    {
                        int?season   = (int?)message["SeasonNumber"];
                        int?episode  = (int?)message["EpisodeNumber"];
                        int startPos = (message["StartPosition"] != null) ? (int)message["StartPosition"] : 0;

                        if (season != null && episode != null)
                        {
                            TVSeriesHelper.Play((int)seriesId, (int)season, (int)episode, resume, startPos);
                        }
                    }
                    // Show movie details for this movie
                    else if (action == "seriesdetails")
                    {
                        TVSeriesHelper.ShowSeriesDetails((int)seriesId);
                    }
                    // Play first unwatched or last added episode of a series
                    else if (action == "playunwatchedepisode")
                    {
                        TVSeriesHelper.PlayFirstUnwatchedEpisode((int)seriesId, resume);
                    }
                    // Play random episode of a series
                    else if (action == "playrandomepisode")
                    {
                        TVSeriesHelper.PlayRandomEpisode((int)seriesId, resume);
                    }
                    // Play all episodes of a season
                    else if (action == "playseason")
                    {
                        int? season               = (int?)message["SeasonNumber"];
                        bool onlyUnwatched        = (message["OnlyUnwatchedEpisodes"] != null) ? (bool)message["OnlyUnwatchedEpisodes"] : false;
                        int  startIndex           = (message["StartIndex"] != null) ? (int)message["StartIndex"] : 0;
                        bool switchToPlaylistView = (message["SwitchToPlaylist"] != null) ? (bool)message["SwitchToPlaylist"] : true;
                        bool startAutomatically   = (message["AutoStart"] != null) ? (bool)message["AutoStart"] : true;
                        if (season != null)
                        {
                            TVSeriesHelper.PlaySeason((int)seriesId, (int)season, startAutomatically, startIndex, onlyUnwatched, switchToPlaylistView);
                        }
                    }
                    // Play all episodes of a series
                    else if (action == "playseries")
                    {
                        bool onlyUnwatched        = (message["OnlyUnwatchedEpisodes"] != null) ? (bool)message["OnlyUnwatchedEpisodes"] : false;
                        int  startIndex           = (message["StartIndex"] != null) ? (int)message["StartIndex"] : 0;
                        bool switchToPlaylistView = (message["SwitchToPlaylist"] != null) ? (bool)message["SwitchToPlaylist"] : true;
                        bool startAutomatically   = (message["AutoStart"] != null) ? (bool)message["AutoStart"] : true;

                        TVSeriesHelper.PlaySeries((int)seriesId, startAutomatically, startIndex, onlyUnwatched, switchToPlaylistView);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Show the details of a mediaitem on MediaPortal (without actually starting playback)
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="mediaType"></param>
        /// <param name="providerId"></param>
        /// <param name="playInfo"></param>
        internal static void ShowMediaItem(string itemId, int mediaType, int providerId, Dictionary <string, string> playInfo)
        {
            try
            {
                MpExtendedProviders  provider = (MpExtendedProviders)providerId;
                MpExtendedMediaTypes type     = (MpExtendedMediaTypes)mediaType;
                switch (provider)
                {
                case MpExtendedProviders.MovingPictures:
                    if (WifiRemote.IsAvailableMovingPictures)
                    {
                        MovingPicturesHelper.ShowMovieDetails(Int32.Parse(playInfo["Id"]));
                    }
                    else
                    {
                        WifiRemote.LogMessage("MovingPictures not installed but required!", WifiRemote.LogType.Error);
                    }
                    break;

                case MpExtendedProviders.MPTvSeries:
                    if (WifiRemote.IsAvailableTVSeries)
                    {
                        if (type == MpExtendedMediaTypes.TVEpisode)
                        {
                            TVSeriesHelper.ShowEpisodeDetails(Int32.Parse(playInfo["ShowId"]), Int32.Parse(playInfo["SeasonIndex"]), Int32.Parse(playInfo["Id"]));
                        }
                        else if (type == MpExtendedMediaTypes.TVSeason)
                        {
                            TVSeriesHelper.ShowSeasonDetails(Int32.Parse(playInfo["ShowId"]), Int32.Parse(playInfo["SeasonIndex"]));
                        }
                        else if (type == MpExtendedMediaTypes.TVShow)
                        {
                            TVSeriesHelper.ShowSeriesDetails(Int32.Parse(playInfo["Id"]));
                        }
                    }
                    else
                    {
                        WifiRemote.LogMessage("MP-TvSeries not installed but required!", WifiRemote.LogType.Error);
                    }
                    break;

                case MpExtendedProviders.MPMusic:
                    if (type == MpExtendedMediaTypes.MusicTrack)
                    {
                        MpMusicHelper.ShowMusicTrackDetails(Int32.Parse(playInfo["Id"]));
                    }
                    else if (type == MpExtendedMediaTypes.MusicAlbum)
                    {
                        MpMusicHelper.ShowAlbumDetails(playInfo["Artist"], playInfo["Album"]);
                    }
                    else if (type == MpExtendedMediaTypes.MusicArtist)
                    {
                        MpMusicHelper.ShowArtistDetails(playInfo["Artist"]);
                    }
                    break;

                case MpExtendedProviders.MPVideo:
                    MpVideosHelper.ShowVideoDetails(Int32.Parse(playInfo["Id"]));
                    break;

                case MpExtendedProviders.MpVideosShare:
                    if (type == MpExtendedMediaTypes.File)
                    {
                        //TODO: fill myvideos db information instead of just playing the file

                        MpVideosHelper.ShowFileDetails(playInfo["Path"]);
                    }
                    else if (type == MpExtendedMediaTypes.Folder)
                    {
                        string[] extensions = playInfo["Extensions"].Split('|');
                        MpVideosHelper.ShowFolderDetails(playInfo["Path"]);
                    }
                    break;

                case MpExtendedProviders.MpMusicShare:
                    if (type == MpExtendedMediaTypes.File)
                    {
                        MpMusicHelper.ShowFileDetails(playInfo["Path"]);
                    }
                    else if (type == MpExtendedMediaTypes.Folder)
                    {
                        MpMusicHelper.ShowFolderDetails(playInfo["Path"]);
                    }
                    break;

                default:
                    //we have no providers (yet) for tv
                    if (type == MpExtendedMediaTypes.Recording)
                    {
                        if (!WifiRemote.IsAvailableTVPlugin)
                        {
                            WifiRemote.LogMessage("No TVPlugin installed: Aborting showrecording", WifiRemote.LogType.Error);
                            return;
                        }

                        MpTvServerHelper.ShowRecordingDetails(Int32.Parse(playInfo["Id"]));
                    }
                    else if (type == MpExtendedMediaTypes.Tv)
                    {
                        if (!WifiRemote.IsAvailableTVPlugin)
                        {
                            WifiRemote.LogMessage("No TVPlugin installed: Aborting showchannel", WifiRemote.LogType.Error);
                            return;
                        }

                        MpTvServerHelper.ShowTvChannelDetails(Int32.Parse(playInfo["Id"]));
                    }
                    else
                    {
                        WifiRemote.LogMessage("Provider not implemented yet", WifiRemote.LogType.Warn);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                WifiRemote.LogMessage("Error during show of MediaItem: " + ex.ToString(), WifiRemote.LogType.Error);
            }
        }