/// <summary>
        /// Handle an MovingPictures 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 HandleMovingPicturesMessage(Newtonsoft.Json.Linq.JObject message, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            string action = (string)message["Action"];

            if (!string.IsNullOrEmpty(action))
            {
                // Show movie details for this movie
                if (action == "moviedetails")
                {
                    string movieName = (string)message["MovieName"];
                    if (!string.IsNullOrEmpty(movieName))
                    {
                        int movieId = MovingPicturesHelper.GetMovieIdByName(movieName);
                        MovingPicturesHelper.ShowMovieDetails(movieId);
                    }
                }
                // Play a movie with MovingPictures
                else if (action == "playmovie")
                {
                    int    movieId   = (message["MovieId"] != null) ? (int)message["MovieId"] : -1;
                    string movieName = (string)message["MovieName"];
                    bool   resume    = (message["AskToResume"] != null) ? (bool)message["AskToResume"] : true;
                    int    startPos  = (message["StartPosition"] != null) ? (int)message["StartPosition"] : 0;

                    // Play by movie id
                    if (movieId != -1)
                    {
                        MovingPicturesHelper.PlayMovie(movieId, resume, startPos);
                    }
                    else if (!string.IsNullOrEmpty(movieName))
                    {
                        // Play by name
                        MovingPicturesHelper.PlayMovie(movieName, resume, startPos);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Play a media item described by its' MpExtended properties (item id/item type/provider id)
        /// </summary>
        /// <param name="itemId">MpExtended item id</param>
        /// <param name="mediaType">MpExtended media type</param>
        /// <param name="providerId">MpExtended provider id</param>
        /// <param name="playInfo">Additional information to playback the item</param>
        /// <param name="startPos">Start position in the video or playlist</param>
        public static void PlayMediaItem(string itemId, int mediaType, int providerId, Dictionary <string, string> playInfo, int startPos)
        {
            try
            {
                MpExtendedProviders  provider = (MpExtendedProviders)providerId;
                MpExtendedMediaTypes type     = (MpExtendedMediaTypes)mediaType;
                switch (provider)
                {
                case MpExtendedProviders.MovingPictures:
                    if (WifiRemote.IsAvailableMovingPictures)
                    {
                        MovingPicturesHelper.PlayMovie(Int32.Parse(playInfo["Id"]), false, startPos);
                    }
                    else
                    {
                        WifiRemote.LogMessage("MovingPictures not installed but required!", WifiRemote.LogType.Error);
                    }
                    break;

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

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

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

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

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

                case MpExtendedProviders.MpMusicShare:
                    if (type == MpExtendedMediaTypes.File)
                    {
                        MpMusicHelper.PlayFile(playInfo["Path"], startPos);
                    }
                    else if (type == MpExtendedMediaTypes.Folder)
                    {
                        string[] extensions = playInfo["Extensions"].Split('|');
                        MpMusicHelper.PlayAllFilesInFolder(playInfo["Path"], extensions, startPos);
                    }
                    break;

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

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

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