Ejemplo n.º 1
0
        public void PlayMovie(ApiMovie video)
        {
            if (video == null)
            {
                return;
            }
            if (!_parent.IsConnected())
            {
                return;
            }

            EmbyPlayPlayList(video.Path);
            _parent.Trace("Attemping to Play IdEpsiode equals" + video.Path);

            /*
             * var args = new JsonObject();
             * var items = new JsonObject();
             * args["movieid"] = video.IdMovie;
             * items["item"] = args;
             * items["playlistid"] = 1;
             * var plId = new JsonObject();
             * plId["playlistid"] = 1;
             * var item = new JsonObject();
             * item["item"] = plId;
             * _parent.JsonCommand("Playlist.Clear", plId);
             * _parent.JsonCommand("Playlist.Add", items);
             * _parent.JsonCommand("Player.Open", item);
             */
        }
Ejemplo n.º 2
0
        public void AsyncPlayFiles(Collection <ApiAudioSong> songs)
        {
            // var songs = (Collection<ApiAudioSong>)e.Argument;


            _parent.Trace("-----------PLAYLIST Songs:  Trying to play songs #:" + songs.Count + "and Globals.SessionID:" + Globals.SessionIDClient);
            if (songs == null)
            {
                return;
            }
            if (!_parent.IsConnected())
            {
                return;
            }


            StringBuilder stringlistIds = new StringBuilder();



            foreach (var apiAudioSong in songs)
            {
                stringlistIds.Append(apiAudioSong.Path).Append(",");
            }

            string ListItems = stringlistIds.ToString(0, stringlistIds.Length - 1);


            _parent.Trace("PLAYFILES Attempting to Play :" + ListItems);
            EmbyPlayPlayList(ListItems);



            /*
             * _bw.CancelAsync();
             * while (_bw.IsBusy)
             * {
             *  Thread.Sleep(50);
             *  System.Windows.Forms.Application.DoEvents();
             * }
             * _bw.RunWorkerAsync(songs);
             */
        }
Ejemplo n.º 3
0
        public bool Download(string fileName, string destination)
        {
            _parent.Trace("----------DOWNLOAD IMAGES ISSUE:  fileNAME is" + fileName + "  : Destination is: " + destination);

            if (!_parent.IsConnected())
            {
                _parent.Trace(" ---------------DOWNLOAD ISSUES ISSUE:  PARENT NOT CONNECTING RETURNING FALSE");
                return(false);
            }

            try
            {
                using (var client = new WebClient())
                {
                    var credentials = _parent.GetCredentials();


                    if (credentials != null)
                    {
                        client.Credentials = credentials;
                    }

                    client.Headers.Add("X-MediaBrowser-Token", Globals.EmbyAuthToken);
                    //Add Header Client - ? helps
                    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

                    client.DownloadFile(_parent.GetDownloadPath(fileName), destination);
                }
                _parent.Trace("DOWNLOAD : " + fileName);
                return(true);
            }
            catch (WebException ex)
            {
                _parent.Trace("EMBY DOWNLOAD ERROR - DOWNLOAD : " + _parent.GetDownloadPath(fileName) + " " + ex.Message);
            }
            catch (System.Exception ex)
            {
                _parent.Trace("EMBY DOWNLOAD ISSUE: EXCEPTION CAUGHT:" + ex);
            }
            return(false);
        }
Ejemplo n.º 4
0
 public void ToggleMute()
 {
     if (_parent.MpcLoaded)
     {
         _parent.MpcHcRemote.ToggleMute();
     }
     else
     if (_parent.IsConnected())
     {
         var mute = new JsonObject();
         mute["mute"] = "toggle";
         _parent.AsyncJsonCommand("Application.SetMute", mute);
     }
 }
Ejemplo n.º 5
0
        public void RefreshNowPlaying()
        {
            lock (Locker)
            {
                /*if (_parent.MpcLoaded)
                 * {
                 *  var result = _parent.MpcHcRemote.GetStatus();
                 *  var result2 = new ArrayList();
                 *  MpcHcRemote.ParseCSVFields(result2, result);
                 *  var data = (string[])result2.ToArray(typeof(string));
                 *  if (data.Length > 6)
                 *  {
                 *      _nowPlaying.MediaType = "Video";
                 *      _nowPlaying.Title = "Media Player Classic";
                 *      _nowPlaying.Time = new TimeSpan(0, 0, 0, Convert.ToInt32("0" + data[2]) / 1000);
                 *      _nowPlaying.Duration = new TimeSpan(0, 0, 0, Convert.ToInt32("0" + data[4]) / 1000);
                 *      var percent = Math.Floor(100.0 * Convert.ToInt32("0" + data[2], CultureInfo.InvariantCulture) / Convert.ToInt32("0" + data[4], CultureInfo.InvariantCulture));
                 *      if (Double.IsNaN(percent))
                 *          percent = 0;
                 *      _nowPlaying.Volume = Convert.ToInt32("0" + data[7], CultureInfo.InvariantCulture);
                 *      _nowPlaying.IsMuted = data[6] == "1";
                 *      _nowPlaying.Progress = (int)percent;
                 *
                 *      if (data[1] == "Playing")
                 *      {
                 *          _parent.Log("XBMC PLAYER REMOTE:   Playing given Changing NowPlaying to true " + data[1]);
                 *          _nowPlaying.IsPlaying = true;
                 *          _nowPlaying.IsPaused = false;
                 *      }
                 *      if (data[1] == "Paused")
                 *      {
                 *          _parent.Log("XBMC PLAYER REMOTE:   Paused given Changing NowPlaying to true " + data[1]);
                 *          _nowPlaying.IsPaused = true;
                 *          _nowPlaying.IsPlaying = !_nowPlaying.IsPaused;
                 *      }
                 *
                 *  }
                 *  if (_parent.MpcLoaded == false)
                 *  {
                 *      _nowPlaying.FileName = "Glenn MPC Stopped";
                 *      _nowPlaying.Title = "";
                 *      _nowPlaying.IsPlaying = false;
                 *      _nowPlaying.IsPaused = false;
                 *  }
                 * }
                 * else
                 * {
                 *  if (!_parent.IsConnected())
                 *  {
                 *      _nowPlaying.FileName = "";
                 *      _nowPlaying.Title = "";
                 *      _nowPlaying.IsPlaying = false;
                 *      _nowPlaying.IsPaused = false;
                 *      _parent.Log("XBMC PLAYER REMOTE:   Returning as no !Player Connected");
                 *
                 *      return;
                 *  }
                 *  //_parent.Log("XBMC PLAYER REMOTE:   Check with MPC Doesnt make it here");
                 *  /*
                 */
                /*
                 * var GUIproperties = new JsonObject();
                 * GUIproperties["properties"] = new[]
                 *                                   {
                 *                                       "currentwindow"
                 *
                 *
                 *                                     };
                 *
                 * var menuresult = (JsonObject)_parent.JsonCommand("GUI.GetProperties", GUIproperties);
                 * var GUIdeeper = (JsonObject)menuresult["currentwindow"];
                 * _nowPlaying.CurrentMenuLabel = GUIdeeper["label"].ToString();
                 * _nowPlaying.CurrentMenuID = GUIdeeper["id"].ToString();
                 *
                 *
                 * var current = -1;
                 * var players = (JsonArray)_parent.JsonCommand("Player.GetActivePlayers", null);
                 *
                 *
                 * if (players.Count > 0)
                 * {
                 *     foreach (JsonObject player in players)
                 *     {
                 *         if (player["type"].ToString() == "picture")
                 *             continue;
                 *         current = Int32.Parse(player["playerid"].ToString());
                 *         _nowPlaying.MediaType = (string)player["type"];
                 *     }
                 * }
                 *
                 * if (current == -1)
                 * {
                 *     _nowPlaying.FileName = "";
                 *     _nowPlaying.Title = "";
                 *     _nowPlaying.IsPlaying = false;
                 *     _nowPlaying.IsPaused = false;
                 *     return;
                 * }
                 *
                 * var items = new JsonObject();
                 * items["playerid"] = current;
                 * items["properties"] = new[]{
                 *                         "file",
                 *                         "comment",
                 *                         "tvshowid",
                 *                         "albumartist",
                 *                         "duration",
                 *                         //"id",
                 *                         "album",
                 *                         //"votes",
                 *                        // "mpaa",
                 *                        // "writer",
                 *                        //"albumid",
                 *                         //"type",
                 *                         "genre",
                 *                         "year",
                 *                         //"plotoutline",
                 *                         "track",
                 *                         "artist",
                 *                         //"season",
                 *                         //"imdbnumber",
                 *                        // "studio",
                 *                         //"showlink",
                 *                         "showtitle",
                 *                         "episode",
                 *                         "season",
                 *                         "plot",
                 *                         "director",
                 *                         "studio",
                 *                         "rating",
                 *                         //"productioncode",
                 *                         //"country",
                 *                         //"premiered",
                 *                         //"originaltitle",
                 *                         //"artistid",
                 *                         //"firstaired",
                 *                         "tagline",
                 *                         "thumbnail",
                 *                         "fanart"
                 *                         //"top250",
                 *                         //"trailer"
                 *                     };
                 *
                 * var properties = new JsonObject();
                 * properties["playerid"] = current;
                 * properties["properties"] = new[]{
                 *                         "totaltime",
                 *                         "percentage",
                 *                         "time",
                 *                         "speed"
                 *                     };
                 *
                 * var appproperties = new JsonObject();
                 * appproperties["properties"] = new[]
                 *                                   {
                 *                                       "muted",
                 *                                       "volume"
                 *                                   };
                 *
                 * var result1 = (JsonObject)_parent.JsonCommand("Player.GetProperties", properties);
                 * var result2 = (JsonObject)_parent.JsonCommand("Player.GetItem", items);
                 * var result3 = (JsonObject)_parent.JsonCommand("Application.GetProperties", appproperties);
                 *
                 *
                 * if (result1 == null || result2 == null || result3 == null)
                 * {
                 *     _nowPlaying.FileName = "";
                 *     _nowPlaying.Title = "";
                 *     _nowPlaying.IsPlaying = false;
                 *     _nowPlaying.IsPaused = false;
                 *     return;
                 * }
                 *
                 * result2 = (JsonObject)(result2)["item"];
                 *
                 *
                 *
                 *
                 *
                 *
                 *
                 * if (_nowPlaying.MediaType == "video")
                 * {
                 *     if (result2["type"].ToString() == "channel")  //if PVR Needs to go high otherwise exception
                 *     {
                 *         _nowPlaying.MediaType = "Pvr";
                 *         _nowPlaying.IsNewMedia = true;
                 *         _nowPlaying.FileName = result2["label"].ToString();
                 *         _nowPlaying.ThumbURL = result2["thumbnail"].ToString();
                 *         _nowPlaying.FanartURL = result2["fanart"].ToString();
                 *         _nowPlaying.Title = result2["label"].ToString();
                 *         _nowPlaying.IsPaused = Convert.ToInt32("0" + result1["speed"].ToString().Replace("-", "")) == 0;
                 *         _nowPlaying.IsPlaying = !_nowPlaying.IsPaused;
                 *         var pvrtime = (JsonObject)result1["time"];
                 *         var pvrtotal = (JsonObject)result1["totaltime"];
                 *         _nowPlaying.Time = new TimeSpan(0, Convert.ToInt32("0" + pvrtime["hours"]), Convert.ToInt32("0" + pvrtime["minutes"]), Convert.ToInt32("0" + pvrtime["seconds"]));
                 *         _nowPlaying.Duration = new TimeSpan(0, Convert.ToInt32("0" + pvrtotal["hours"]), Convert.ToInt32("0" + pvrtotal["minutes"]), Convert.ToInt32("0" + pvrtotal["seconds"]));
                 *         _nowPlaying.Progress = Convert.ToInt32("0" + result1["percentage"].ToString().Split('.')[0]);
                 *         _nowPlaying.Volume = Convert.ToInt32("0" + result3["volume"]);
                 *         _nowPlaying.IsMuted = (bool)result3["muted"];
                 *         return;
                 *     }
                 * }
                 *
                 * _nowPlaying.IsPaused = Convert.ToInt32("0" + result1["speed"].ToString().Replace("-", "")) == 0;
                 * _nowPlaying.IsPlaying = !_nowPlaying.IsPaused;
                 * var time = (JsonObject)result1["time"];
                 * var total = (JsonObject)result1["totaltime"];
                 * _nowPlaying.Time = new TimeSpan(0, Convert.ToInt32("0" + time["hours"]), Convert.ToInt32("0" + time["minutes"]), Convert.ToInt32("0" + time["seconds"]));
                 * _nowPlaying.Duration = new TimeSpan(0, Convert.ToInt32("0" + total["hours"]), Convert.ToInt32("0" + total["minutes"]), Convert.ToInt32("0" + total["seconds"]));
                 * _nowPlaying.Progress = Convert.ToInt32("0" + result1["percentage"].ToString().Split('.')[0]);
                 * _nowPlaying.Volume = Convert.ToInt32("0" + result3["volume"]);
                 * _nowPlaying.IsMuted = (bool)result3["muted"];
                 *
                 * _parent.MpcLoaded = _nowPlaying.Duration == new TimeSpan(0, 0, 0, 1);
                 *
                 * _nowPlaying.FileName = result2["file"].ToString();
                 *
                 * if (_nowPlaying.MediaType == "audio")
                 * {
                 *     _nowPlaying.MediaType = "Audio";
                 *     _nowPlaying.Genre = _parent.JsonArrayToString((JsonArray)result2["genre"]);
                 *     _nowPlaying.Title = result2["label"].ToString();
                 *     _nowPlaying.Year = Convert.ToInt32("0" + result2["year"]);
                 *     _nowPlaying.Track = Convert.ToInt32("0" + result2["track"]);
                 *     _nowPlaying.Artist = _parent.JsonArrayToString((JsonArray)result2["artist"]);
                 *     _nowPlaying.Album = result2["album"].ToString();
                 *     _nowPlaying.ThumbURL = result2["thumbnail"].ToString();
                 *     _nowPlaying.FanartURL = result2["fanart"].ToString();
                 * }
                 *
                 * if (_nowPlaying.MediaType == "video")
                 * {
                 *     _nowPlaying.MediaType = result2["type"].ToString() == "episode" ? "TvShow" : "Movie";
                 *
                 *
                 *
                 *     _nowPlaying.Genre = _parent.JsonArrayToString((JsonArray)result2["genre"]);
                 *     _nowPlaying.Title = result2["label"].ToString();
                 *     _nowPlaying.Year = Convert.ToInt32("0" + result2["year"]);
                 *     _nowPlaying.SeasonNumber = Convert.ToInt32("0" + result2["season"].ToString().Replace("-", ""));
                 *     _nowPlaying.EpisodeNumber = Convert.ToInt32("0" + result2["episode"].ToString().Replace("-", ""));
                 *     _nowPlaying.ShowTitle = result2["showtitle"].ToString();
                 *     _nowPlaying.Plot = result2["plot"].ToString();
                 *     _nowPlaying.Director = _parent.JsonArrayToString((JsonArray)result2["director"]);
                 *     _nowPlaying.Studio = _parent.JsonArrayToString((JsonArray)result2["studio"]);
                 *     _nowPlaying.Tagline = result2["tagline"].ToString();
                 *     _nowPlaying.Rating = result2["rating"].ToString();
                 *     _nowPlaying.ThumbURL = result2["thumbnail"].ToString();
                 *     _nowPlaying.FanartURL = result2["fanart"].ToString();
                 * }
                 */
                if (!_parent.IsConnected())
                {
                    _nowPlaying.FileName  = "";
                    _nowPlaying.Title     = "";
                    _nowPlaying.IsPlaying = false;
                    _nowPlaying.IsPaused  = false;
                    _parent.Log("Emby PLAYER REMOTE:   Returning as no !Player Connected");

                    return;
                }



                try
                {
                    _parent.Trace("Emby: Using Parent IP equals: " + _parent.IP);
                    string NPurl   = "http://" + _parent.IP + ":" + _parent.Port;
                    var    request = WebRequest.CreateHttp(NPurl + "/FrontView");

                    request.Method = "get";
                    //request.Timeout = 5000;
                    _parent.Log("--------------- PLAYER CONNECTION: IP " + _parent.IP + ":" + _parent.Port);



                    var authString = _parent.GetAuthString();



                    _parent.Log("------------------- Username Parent :" + _parent.UserName);
                    _parent.Log("------------------- CurrentUserID Parent :" + _parent.CurrentUserID);
                    _parent.Log("------------------- EMBY TOKEN EQUALS :" + Globals.EmbyAuthToken);

                    //_parent.Log("AuthString " + authString);


                    request.Headers.Add("X-MediaBrowser-Token", Globals.EmbyAuthToken);


                    request.KeepAlive = false;
                    request.Headers.Add("Authorization", authString);
                    request.ContentType = "application/json; charset=utf-8";
                    //  request.ContentLength = postArg.Length;
                    request.Accept = "application/json";


                    var response = request.GetResponse();


                    if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK)
                    {
                        //  Use MPC Remote

                        _parent.MpcLoaded = true;


                        System.IO.Stream dataStream = response.GetResponseStream();

                        //REMOVETHIS                           System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);

                        using (var sr = new System.IO.StreamReader(response.GetResponseStream()))
                        {
                            string json = sr.ReadToEnd();
                            _parent.Trace("--------------Using FrontView Emby Plugin Data   ------" + json);
                            var deserializer = new JavaScriptSerializer();

                            var server = deserializer.Deserialize <EmbyServerPlugin.ApiInfo>(json);
                            _parent.Trace("------------- FrontView Emby Plugin: Now Checking Results :results.Count:" + server.Filename);



                            //Check Something is Playing and Return
                            //If Doesnt return - something must be playing.
                            _parent.Trace("------------- FrontView Emby Plugin:  server.Filename equals:" + server.Filename);
                            if (String.IsNullOrEmpty(server.Filename))
                            {
                                _nowPlaying.FileName  = "";
                                _nowPlaying.Title     = "";
                                _nowPlaying.IsPlaying = false;
                                _nowPlaying.IsPaused  = false;
                                _nowPlaying.IsPlaying = false;
                                _parent.Trace("--------------EMBY NOW PLAYING Log: Nothing is Playing");
                                response.Close();
                                return;
                            }
                            // OK - Ignore these filenames theme.mp3 for one
                            // ? Video Backgrounds as well will figure out
                            //
                            if (server.Filename.EndsWith("theme.mp3") || server.Filename.EndsWith("theme.mp4"))
                            {
                                _nowPlaying.FileName  = "";
                                _nowPlaying.Title     = "";
                                _nowPlaying.IsPlaying = false;
                                _nowPlaying.IsPaused  = false;
                                _nowPlaying.IsPlaying = false;
                                _parent.Trace("--------------Emby Now Playing Theme Video NowPlaying IGNORE This. Filename:" + server.Filename);
                                response.Close();
                                return;
                            }

                            //Something must be playing- at least something with a filename
                            //We will find out how full proof that is later.

                            //_nowPlaying.IsNewMedia = true;

                            _parent.Trace("-------------- Emby Emby Plugin:  IsNewMedia:" + _nowPlaying.IsNewMedia);
                            if (server.Filename != null)
                            {
                                if (server.IsPaused == true)
                                {
                                    _nowPlaying.IsPlaying = false;
                                    _nowPlaying.IsPaused  = true;
                                }
                                if (server.IsPaused == false)
                                {
                                    _nowPlaying.IsPlaying = true;
                                    _nowPlaying.IsPaused  = false;
                                }

                                if (server.MediaType == "Audio")
                                {
                                    _nowPlaying.MediaType = "Audio";

                                    _nowPlaying.Album = server.Album;
                                    _nowPlaying.Year  = Convert.ToInt32("0" + server.Year);
                                    _nowPlaying.Track = Convert.ToInt32("0" + server.EpisodeNumber);

                                    _nowPlaying.Title    = server.Title;
                                    _nowPlaying.FileName = server.Filename;
                                    _parent.Log("------------- EMBY Trying to get Audio Images");
                                    _parent.Log("------------- EMBY IMAGES: FanartURL " + "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop");

                                    _nowPlaying.FanartURL = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.BackdropItemId + "/Images/Primary";

                                    _nowPlaying.ThumbURL = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Primary";
                                    _nowPlaying.Artist   = server.Artist;
                                }


                                if (server.MediaType == "Episode")
                                {
                                    _nowPlaying.MediaType     = "TvShow";
                                    _nowPlaying.EpisodeNumber = Convert.ToInt32("0" + server.EpisodeNumber);
                                    _nowPlaying.SeasonNumber  = Convert.ToInt32("0" + server.SeasonNumber);
                                    _nowPlaying.ShowTitle     = String.IsNullOrEmpty(server.ShowTitle) ? "" : server.ShowTitle;
                                    _nowPlaying.Title         = String.IsNullOrEmpty(server.Title) ? "Blank" : server.Title;
                                    _nowPlaying.Plot          = String.IsNullOrEmpty(server.Overview) ? "" : server.Overview;
                                    _nowPlaying.FileName      = server.Filename; //Filename
                                    _parent.Log("------------- EMBY Trying to get Images");
                                    _parent.Log("------------- EMBY IMAGES: FanartURL " + "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop");
                                    _nowPlaying.FanartURL = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.BackdropItemId + "/Images/Backdrop";
                                    _nowPlaying.ThumbURL  = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Primary";
                                }

                                if (server.MediaType == "ChannelVideoItem")
                                {
                                    _nowPlaying.MediaType = "Movie";
                                    //_nowPlaying.ShowTitle = server.NowPlayingItem.SeriesName;
                                    _nowPlaying.Title    = server.Title;
                                    _nowPlaying.FileName = server.Filename;      //No Filename as yet try ID
                                    _parent.Log("------------- EMBY Trying to get Images");
                                    _parent.Log("------------- EMBY IMAGES: FanartURL " + "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop");
                                    _nowPlaying.FanartURL = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop";
                                    _nowPlaying.ThumbURL  = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Primary";
                                }

                                if (server.MediaType == "Movie")
                                {
                                    _nowPlaying.MediaType = "Movie";
                                    //_nowPlaying.EpisodeNumber = server.NowPlayingItem.IndexNumber;
                                    // _nowPlaying.SeasonNumber = server.NowPlayingItem.ParentIndexNumber;
                                    // _nowPlaying.ShowTitle = server.NowPlayingItem.SeriesName;
                                    _nowPlaying.Title    = server.Title;
                                    _nowPlaying.Plot     = server.Overview;
                                    _nowPlaying.Director = server.Director;
                                    _nowPlaying.Rating   = server.Rating;
                                    _nowPlaying.FileName = server.Filename;
                                    _parent.Log("------------- EMBY Trying to get Images");
                                    _parent.Log("------------- EMBY IMAGES: FanartURL " + "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop");
                                    _nowPlaying.FanartURL = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop";
                                    _nowPlaying.ThumbURL  = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Primary";
                                }

                                if (server.MediaType == "Video")
                                {
                                    _nowPlaying.MediaType = "Movie";
                                    //_nowPlaying.EpisodeNumber = server.NowPlayingItem.IndexNumber;
                                    // _nowPlaying.SeasonNumber = server.NowPlayingItem.ParentIndexNumber;
                                    // _nowPlaying.ShowTitle = server.NowPlayingItem.SeriesName;
                                    _nowPlaying.Title    = server.Title;
                                    _nowPlaying.Plot     = server.Overview;
                                    _nowPlaying.Director = server.Director;
                                    _nowPlaying.Rating   = server.Rating;
                                    _nowPlaying.FileName = server.Filename;
                                    _parent.Log("------------- EMBY Trying to get Images");
                                    _parent.Log("------------- EMBY IMAGES: FanartURL " + "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop");
                                    _nowPlaying.FanartURL = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop";
                                    _nowPlaying.ThumbURL  = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Primary";
                                }

                                var Seconds      = Convert.ToInt64(server.Duration);
                                var TimePosition = Convert.ToInt64(server.TimePosition);
                                var RoundSeconds = Math.Round(Seconds / 10000000.00, 1);
                                var RoundTime    = Math.Round(TimePosition / 10000000.00, 2);
                                //_parent.Log("--------------TIME CONVERSION BUGGER: RoundSeconds:" + RoundSeconds + " Orginal Time RunTimeTicks:"+server.NowPlayingItem.RunTimeTicks);
                                _nowPlaying.Duration = new TimeSpan(0, 0, 0, Convert.ToInt32(RoundSeconds));

                                _nowPlaying.Time = new TimeSpan(0, 0, 0, Convert.ToInt32(RoundTime));


                                double percent = (100.0 * TimePosition) / Seconds;
                                percent = Math.Round(percent, 0);

                                //Change to Primary Image - seems to be better format.
                                _parent.Log("Percent of Time equals:" + percent);
                                if (Double.IsNaN(percent))
                                {
                                    percent = 0;
                                }

                                _nowPlaying.Progress = (int)percent;

                                _nowPlaying.IsMuted = server.IsMuted;
                                _nowPlaying.Volume  = Convert.ToInt32(server.Volume);
                                _nowPlaying.Tagline = server.Tagline;
                                _nowPlaying.Studio  = server.Studio;
                                if (server.AirDate.HasValue)
                                {
                                    _nowPlaying.FirstAired = server.AirDate.Value;
                                }
                                response.Close();
                                return;
                            }
                        }
                    }
                    else   //Hopefully is HTTP Status Not OK
                    {
                        _nowPlaying.FileName  = "";
                        _nowPlaying.Title     = "";
                        _nowPlaying.IsPlaying = false;
                        _nowPlaying.IsPaused  = false;
                        _nowPlaying.IsPlaying = false;
                        _parent.Trace("--------------EMBY NOW PLAYING Log: Nothing is Playing");
                        response.Close();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    _parent.Log("Exception in NowPlaying EMBY System" + ex);
                    _parent.MpcLoaded = false;

                    return;
                }
            }
        }