Exemple #1
0
        void player_PlayBegin(YoutubePlaylistPlayer playlit, PlayListItem item)
        {
            try
            {
                //ClearLabels("NowPlaying");
                VideoInfo info = item.MusicTag as VideoInfo;
                if (info == null)
                {
                    return;
                }

                Log.Debug("YouTube.fm playback started");
                YouTubeEntry en = info.Entry;

                if (en.Authors.Count == 0)
                {
                    Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + Youtube2MP.GetVideoId(en));
                    try
                    {
                        Video video = Youtube2MP.request.Retrieve <Video>(videoEntryUrl);
                        en = video.YouTubeEntry;
                    }
                    catch (Exception)
                    {
                        //vid = null;
                    }
                }

                en.Title.Text = item.Description;
                item.FileName = Youtube2MP.StreamPlaybackUrl(en, info);
                ClearLabels("NowPlaying", true);
                ClearLabels("Next", true);
                Youtube2MP.NowPlayingEntry  = en;
                Youtube2MP.NextPlayingEntry = null;
                //ArtistManager.Instance.SetSkinProperties(Youtube2MP.NextPlayingEntry, "NowPlaying", false, false);
                if (playlit.GetNextItem() != null)
                {
                    VideoInfo nextinfo = playlit.GetNextItem().MusicTag as VideoInfo;
                    if (nextinfo != null)
                    {
                        Youtube2MP.NextPlayingEntry = nextinfo.Entry;
                        //ArtistManager.Instance.SetSkinProperties(Youtube2MP.NextPlayingEntry, "Next", false, false);
                    }
                }
                BackgroundWorker playBeginWorker = new BackgroundWorker();
                playBeginWorker.DoWork += playBeginWorker_DoWork;
                playBeginWorker.RunWorkerAsync();
                Youtube2MP.YouTubePlaying = true;
                GUIPropertyManager.SetProperty("#Youtube.fm.FullScreen.ShowTitle", "true");
                GUIPropertyManager.SetProperty("#Youtube.fm.FullScreen.ShowNextTitle",
                                               Youtube2MP.NextPlayingEntry != null ? "true" : "false");
                _labelTimer.Stop();
                _labelTimer.Start();
            }
            catch (Exception exception)
            {
                Log.Error("Youtube play begin exception");
                Log.Error(exception);
            }
        }
    private void GetTrackTags()
    {
      if (CurrentTrackTag != null)
      {
        PreviousTrackTag = CurrentTrackTag;
      }

      bool isInternetStream = Util.Utils.IsAVStream(CurrentTrackFileName) && !Util.Utils.IsLastFMStream(CurrentTrackFileName);
      if (isInternetStream && _usingBassEngine)
      {
        NextTrackTag = null;
        return;
      }

      PlayListItem currentItem = PlaylistPlayer.GetCurrentItem();
      PlayListItem nextItem = PlaylistPlayer.GetNextItem();
      if (currentItem != null)
      {
        CurrentTrackTag = (MusicTag)currentItem.MusicTag;
      }
      else
      {
        CurrentTrackTag = null;
      }

      if (nextItem != null)
      {
        NextTrackTag = (MusicTag)nextItem.MusicTag;
      }
      else
      {
        NextTrackTag = null;
      }

    }
        /// <summary>
        /// 双击歌曲项或右键点击播放
        /// </summary>
        /// <param name="listBox"></param>
        private void DouClickSongItemExecute(Selector listBox)        //由于PlayListItem在子类中无法改变,故放于此
        {
            var songListItem = listBox.SelectedItem as SongListStyle;

            if (songListItem != null)
            {
                var targetSong = SongListModel.GetPlayingSong(songListItem.Song.Path);
                if (!targetSong.Equals(PlayingSong))
                {
                    PlayingSong = targetSong;
                }
                //PlayingSong = SongListModel.GetPlayingSong(songListItem.Song.Path);
            }

            PlayListItem.Clear();
            PlayListItem = new List <SongListStyle>(InitialSongs);

            IsPlayListChanged = true;            //播放列表被修改

            PlayingListModel.ClearPlayingList();
            PlayingListModel.SavePlayingList(PlayListItem.Select(i => i.Song).ToList());
            if (ControlService.PlayState != PlayState.播放)
            {
                ControlService.PlayState = PlayState.播放;
            }
            else
            {
                ControlService.PlayService.MediaPlayer.Play();
            }
        }
Exemple #4
0
        /// <summary>
        /// Add selected item to end of Playlist
        /// </summary>
        /// <param name="listItem"></param>
        private void addToPlaylistNext(GUIListItem listItem)
        {
            PlayList     playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL);
            PlayListItem item     = new PlayListItem(listItem.TVTag as DBTrackInfo);

            playlist.Insert(item, Player.playlistPlayer.CurrentItem);
        }
Exemple #5
0
        public string Get(int iSong)
        {
            if (_currentPlayList == PlayListType.PLAYLIST_NONE)
            {
                return(string.Empty);
            }

            PlayList playlist = GetPlaylist(_currentPlayList);

            if (playlist.Count <= 0)
            {
                return(string.Empty);
            }

            if (iSong >= playlist.Count)
            {
                //	Is last element of video stacking playlist?
                if (_currentPlayList == PlayListType.PLAYLIST_VIDEO_TEMP)
                {
                    return(string.Empty);
                }

                if (!_repeatPlayList)
                {
                    return(string.Empty);

                    ;
                }
                iSong = 0;
            }

            PlayListItem item = playlist[iSong];

            return(item.FileName);
        }
Exemple #6
0
 public void addSongs(string[] songs, int select = -1)
 {
     foreach (string fname in songs)
     {
         if (File.Exists(fname))
         {
             PlayListItem pi = new PlayListItem();
             pi.name = Path.GetFileName(fname);
             string dir = Path.GetDirectoryName(fname) + Path.DirectorySeparatorChar;
             pi.dirIndex = directoryList.IndexOf(dir);
             if (pi.dirIndex < 0)
             {
                 pi.dirIndex = directoryList.Count;
                 directoryList.Add(dir);
             }
             songList.Add(pi);
             listView1.Items.Add(pi.ToString());
         }
     }
     if (select > -1)
     {
         clearImages();
         ListViewItem item = listView1.Items[listView1.Items.Count - songs.Length + select];
         item.Selected   = true;
         item.ImageIndex = 0;
         listView1.Select();
     }
 }
Exemple #7
0
        /// <summary>
        /// Adds a list of Music Videos to a playlist, or a list of artists Music Videos
        /// </summary>
        /// <param name="items"></param>
        /// <param name="playNow"></param>
        /// <param name="clear"></param>
        private void AddToPlaylist(List <DBTrackInfo> items, bool playNow, bool clear, bool shuffle)
        {
            PlayList playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL);

            if (clear)
            {
                playlist.Clear();
            }
            foreach (DBTrackInfo video in items)
            {
                PlayListItem p1 = new PlayListItem(video);
                p1.Track    = video;
                p1.FileName = video.LocalMedia[0].File.FullName;
                playlist.Add(p1);
            }
            Player.playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL;
            if (shuffle)
            {
                playlist.Shuffle();
            }
            if (playNow)
            {
                Player.playlistPlayer.Play(0);
                if (mvCentralCore.Settings.AutoFullscreen)
                {
                    logger.Debug("Switching to Fullscreen");
                    GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);
                }
            }
        }
        /// <summary>
        /// Adds songs to a playlist by querying the music database
        /// </summary>
        /// <param name="type">Type of the playlist</param>
        /// <param name="where">SQL where condition</param>
        /// <param name="limit">Maximum number of songs</param>
        /// <param name="shuffle"><code>true</code> to shuffle the playlist</param>
        /// <param name="startIndex">Index to at the songs at</param>
        public static void AddSongsToPlaylistWithSQL(string type, string where, int limit, bool shuffle, int startIndex)
        {
            // Only works for music atm
            PlayListType plType = GetTypeFromString(type);

            if (plType == PlayListType.PLAYLIST_MUSIC)
            {
                List <Song> songs = new List <Song>();

                string sql = "select * from tracks where " + where;
                if (shuffle)
                {
                    sql += " ORDER BY random()";
                }

                MusicDatabase.Instance.GetSongsByFilter(sql, out songs, "tracks");
                if (songs.Count > 0)
                {
                    PlayListPlayer playListPlayer         = PlayListPlayer.SingletonPlayer;
                    int            numberOfSongsAvailable = songs.Count - 1;

                    // Limit 0 means unlimited
                    if (limit == 0)
                    {
                        limit = songs.Count;
                    }

                    for (int i = 0; i < limit && i < songs.Count; i++)
                    {
                        PlayListItem playListItem = ToPlayListItem(songs[i]);
                        playListPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Insert(playListItem, startIndex + i);
                    }
                }
            }
        }
Exemple #9
0
        private MusicTag GetTag(string fileName)
        {
            MusicTag tag = null;

            // efforts only for important track
            bool isCurrent = (g_Player.CurrentFile == fileName);

            PlayListItem item = null;

            if (isCurrent)
            {
                item = playlistPlayer.GetCurrentItem();
            }
            else
            {
                item = playlistPlayer.GetNextItem();
            }

            if (item != null)
            {
                tag = (MusicTag)item.MusicTag;
            }

            if (tag == null)
            {
                tag = TagReader.TagReader.ReadTag(fileName);

                if (tag != null)
                {
                    tag.Artist = Util.Utils.FormatMultiItemMusicStringTrim(tag.Artist, _stripArtistPrefixes);
                }
            }

            return(tag);
        }
Exemple #10
0
        void player_PlayBegin(PlayListItem item)
        {
            try
            {
                ClearLabels("NowPlaying");
                VideoInfo info = item.MusicTag as VideoInfo;
                if (info == null)
                {
                    return;
                }

                Log.Debug("YouTube.fm playback started");
                YouTubeEntry en = info.Entry;
                item.FileName = Youtube2MP.StreamPlaybackUrl(en, info);
                Song song = Youtube2MP.YoutubeEntry2Song(en);

                Youtube2MP.NowPlayingEntry = en;
                Youtube2MP.NowPlayingSong  = song;
                SetLabels(en, "NowPlaying");
                if (listControl != null)
                {
                    GUIControl.ClearControl(GetID, listControl.GetID);
                    relatated.Clear();
                }
                infoTimer.Enabled = true;
            }
            catch
            {
            }
        }
 public void addSongs(string[] songs, int select = -1)
 {
     foreach (string fname in songs)
     {
         if (File.Exists(fname))
         {
             PlayListItem pi = new PlayListItem();
             pi.name = Path.GetFileName(fname);
             string dir = Path.GetDirectoryName(fname) + Path.DirectorySeparatorChar;
             pi.dirIndex = directoryList.IndexOf(dir);
             if(pi.dirIndex < 0)
             {
                 pi.dirIndex = directoryList.Count;
                 directoryList.Add(dir);
             }
             songList.Add(pi);
             listView1.Items.Add(pi.ToString());
         }
     }
     if (select > -1)
     {
         clearImages();
         ListViewItem item = listView1.Items[listView1.Items.Count - songs.Length + select];
         item.Selected = true;
         item.ImageIndex = 0;
         listView1.Select();
     }
 }
Exemple #12
0
 /// <summary>
 /// Adds a list of Music Videos to a playlist, or a list of artists Music Videos
 /// </summary>
 /// <param name="items"></param>
 /// <param name="playNow"></param>
 /// <param name="clear"></param>
 private void AddToPlaylist(List<DBTrackInfo> items, bool playNow, bool clear, bool shuffle)
 {
     PlayList playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL);
       if (clear)
       {
     playlist.Clear();
       }
       foreach (DBTrackInfo video in items)
       {
     PlayListItem p1 = new PlayListItem(video);
     p1.Track = video;
     p1.FileName = video.LocalMedia[0].File.FullName;
     playlist.Add(p1);
       }
       Player.playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL;
       if (shuffle)
       {
     playlist.Shuffle();
       }
       if (playNow)
       {
       Player.playlistPlayer.Play(0);
       if (mvCentralCore.Settings.AutoFullscreen)
       {
       logger.Debug("Switching to Fullscreen");
       GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);
       }
       }
 }
Exemple #13
0
        private void LoadButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openMidiFileDialog = new OpenFileDialog()
            {
                DefaultExt = "mid",
                Filter     = "MIDI files|*.mid|All files|*.*",
                Title      = "Open MIDI file"
            };

            if (openMidiFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fileName         = openMidiFileDialog.FileName;
                string filteredFileName = fileName;
                if (fileName.Contains("\\"))
                {
                    string[] fileNameSplit = fileName.Split('\\');
                    filteredFileName = fileNameSplit[fileNameSplit.Length - 1].Replace(".mid", "");
                }
                PlayListItem music = new PlayListItem();
                music.Name = filteredFileName;
                music.Path = fileName;
                PlayListBox.Items.Add(music);
                playListManager.AddTrack(music);
            }
        }
        private void SavePlayList()
        {
            string strNewFileName = playlistPlayer.CurrentPlaylistName;

            if (VirtualKeyboard.GetKeyboard(ref strNewFileName, GetID))
            {
                string strPath         = Path.GetFileNameWithoutExtension(strNewFileName);
                string strPlayListPath = string.Empty;
                using (Profile.Settings xmlreader = new Profile.MPSettings())
                {
                    strPlayListPath = xmlreader.GetValueAsString("music", "playlists", string.Empty);
                    strPlayListPath = Util.Utils.RemoveTrailingSlash(strPlayListPath);
                }

                strPath += ".m3u";
                if (strPlayListPath.Length != 0)
                {
                    strPath = strPlayListPath + @"\" + strPath;
                }
                PlayList playlist = new PlayList();
                for (int i = 0; i < facadeLayout.Count; ++i)
                {
                    GUIListItem  pItem   = facadeLayout[i];
                    PlayListItem newItem = new PlayListItem();
                    newItem.FileName    = pItem.Path;
                    newItem.Description = pItem.Label;
                    newItem.Duration    = (pItem.MusicTag == null) ? pItem.Duration : (pItem.MusicTag as MusicTag).Duration;
                    newItem.Type        = PlayListItem.PlayListItemType.Audio;
                    playlist.Add(newItem);
                }
                IPlayListIO saver = new PlayListM3uIO();
                saver.Save(playlist, strPath);
            }
        }
        private void OnDelPlayList(ListBox listBox)
        {
            var songListItem = listBox.SelectedItem as SongListStyle;

            if (songListItem == null)
            {
                return;
            }
            var delSong  = SongListModel.GetPlayingSong(songListItem.Song.Path);
            var songList = PlayListItem.Select(i => i.Song).ToList();

            songList.Remove(delSong);
            PlayListItem = SongListModel.InitialSongList(songList);

            IsPlayListChanged = true;

            PlayingListModel.ClearPlayingList();
            PlayingListModel.SavePlayingList(songList);

            //若删除的歌曲为正在播放的歌曲
            if (delSong.Equals(PlayingSong))
            {
                OnNext();                //播放下一曲
            }
        }
Exemple #16
0
        protected void OnLast()
        {
            if (PlayListItem == null || PlayListItem.Count == 0)
            {
                return;
            }
            var songList     = PlayListItem.Select(i => i.Song).ToList();
            var playingIndex = songList.IndexOf(PlayingSong);

            if (PlayMode == PlayMode.随机播放 && IsPlayListChanged)
            {
                PlayModeService.ChangeRandomList(songList);
                IsPlayListChanged = false;
            }
            PlayingSong = PlayModeService.OnLastExecute(PlayMode, songList, playingIndex);

            if (ControlService.PlayState != PlayState.播放)
            {
                ControlService.PlayState = PlayState.播放;
            }
            else
            {
                ControlService.PlayService.MediaPlayer.Play();
            }
        }
        protected void LoadPlayList(string strPlayList)
        {
            IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);

            if (loader == null)
            {
                return;
            }
            PlayList playlist = new PlayList();

            if (!loader.Load(playlist, strPlayList))
            {
                TellUserSomethingWentWrong();
                return;
            }

            playlistPlayer.CurrentPlaylistName = Path.GetFileNameWithoutExtension(strPlayList);
            if (playlist.Count == 1)
            {
                Log.Info("GUIVideoFiles: play single playlist item - {0}", playlist[0].FileName);
                if (g_Player.Play(playlist[0].FileName))
                {
                    if (Util.Utils.IsVideo(playlist[0].FileName))
                    {
                        g_Player.ShowFullScreenWindow();
                    }
                }
                return;
            }

            // clear current playlist
            playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Clear();

            // add each item of the playlist to the playlistplayer
            for (int i = 0; i < playlist.Count; ++i)
            {
                PlayListItem playListItem = playlist[i];
                playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Add(playListItem);
            }

            // if we got a playlist
            if (playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Count > 0)
            {
                // then get 1st song
                playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO);
                PlayListItem item = playlist[0];

                // and start playing it
                playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO;
                playlistPlayer.Reset();
                playlistPlayer.Play(0);

                // and activate the playlist window if its not activated yet
                if (GetID == GUIWindowManager.ActiveWindow)
                {
                    GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_PLAYLIST);
                }
            }
        }
Exemple #18
0
 private void OnModeChange()
 {
     PlayMode = PlayModeService.OnModeChange(PlayMode);
     if (PlayMode == PlayMode.随机播放)
     {
         PlayModeService.ChangeRandomList(PlayListItem.Select(i => i.Song).ToList());
     }
 }
 public EditPlayListItemForm(string filePath, Action <PlayListItem> _callback)
 {
     InitializeComponent();
     callback = _callback;
     item     = new PlayListItem {
         FilePath = filePath
     };
 }
        public void NewlyAddedSongsAreNotMarkedPlayed()
        {
            PlayList     pl   = new PlayList();
            PlayListItem item = new PlayListItem("my song", "myfile.mp3");

            pl.Add(item);

            Assert.IsFalse(pl.AllPlayed());
        }
Exemple #21
0
        public bool Load(PlayList playlist, string fileName)
        {
            playlist.Clear();

            try
            {
                var basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
                var doc      = new XmlDocument();
                doc.Load(fileName);
                if (doc.DocumentElement == null)
                {
                    return(false);
                }
                var nodeRoot = doc.DocumentElement.SelectSingleNode("/asx");
                if (nodeRoot == null)
                {
                    return(false);
                }
                var nodeEntries = nodeRoot.SelectNodes("entry");
                foreach (XmlNode node in nodeEntries)
                {
                    var srcNode = node.SelectSingleNode("ref");
                    if (srcNode != null)
                    {
                        var url = srcNode.Attributes.GetNamedItem("href");
                        if (url != null)
                        {
                            if (url.InnerText != null)
                            {
                                if (url.InnerText.Length > 0)
                                {
                                    fileName = url.InnerText;
                                    if (
                                        !(fileName.ToLowerInvariant().StartsWith("http") ||
                                          fileName.ToLowerInvariant().StartsWith("mms") ||
                                          fileName.ToLowerInvariant().StartsWith("rtp")))
                                    {
                                        continue;
                                    }

                                    var newItem = new PlayListItem(fileName, fileName, 0);
                                    newItem.Type = PlayListItem.PlayListItemType.Audio;
                                    playlist.Add(newItem);
                                }
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace);
            }
            return(false);
        }
        public void UpdateListViewWhenContentOfPlayListChange()
        {
            var playList = new PlayList(new PlayListContent(2, "name", new PlayListItem[0]), null);
            m_Model.SelectedPlayListChanged(playList);
            var newItem = new PlayListItem(new ImageId(33), "trentatre");

            playList.AddItem(newItem);

            Assert.That(GetPlayListItemsInListView(), Is.EquivalentTo(new[] {newItem}));
        }
        public void RaiseContentChangeWhenAddItemToPlayList()
        {
            var newItem = new PlayListItem(new ImageId(30), "");
            var playListListener = MockRepository.GenerateMock<PlayListListener>();
            playListListener.Expect(l => l.ContentChanged(new PlayListContent(0, "", new []{newItem})));
            var playList = new PlayList(new PlayListContent(0, "", new PlayListItem[0]), null);
            playList.AddListener(playListListener);

            playList.AddItem(newItem);
        }
        public void UpdateListViewWhenContentOfPlayListChange()
        {
            var playList = new PlayList(new PlayListContent(2, "name", new PlayListItem[0]), null);

            m_Model.SelectedPlayListChanged(playList);
            var newItem = new PlayListItem(new ImageId(33), "trentatre");

            playList.AddItem(newItem);

            Assert.That(GetPlayListItemsInListView(), Is.EquivalentTo(new[] { newItem }));
        }
        public void GetNextReturnsFileName()
        {
            PlayListPlayer player = new PlayListPlayer();

            player.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
            PlayList     playlist = player.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
            PlayListItem item1    = new PlayListItem("apa", "c:\\apa.mp3");

            playlist.Add(item1);
            Assert.AreEqual("c:\\apa.mp3", player.GetNext());
        }
        private static PlayListItem ToPlayListItem(IMDBMovie movie)
        {
            PlayListItem pli = new PlayListItem();

            pli.Type        = PlayListItem.PlayListItemType.Video;
            pli.FileName    = movie.File;
            pli.Description = movie.Title;
            pli.Duration    = movie.RunTime;

            return(pli);
        }
        protected async Task ClickSong(PlayListItem item)
        {
            if (item.Index != SelectedPlayListItem?.Index)
            {
                SelectedPlayListItem = item;

                // Log($"ClickSong : {item.Title}");

                await Player.PlayAsync(item.Index, CancellationToken.None);
            }
        }
        public void RemoveReallyRemovesASong()
        {
            PlayList     pl   = new PlayList();
            PlayListItem item = new PlayListItem("my song", "myfile.mp3");

            pl.Add(item);

            pl.Remove("myfile.mp3");

            Assert.AreEqual(0, pl.Count);
        }
        public void InsertItemButNotStartPlayingGivesNull()
        {
            PlayListPlayer player = new PlayListPlayer();

            player.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC;
            PlayList     playlist = player.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
            PlayListItem item1    = new PlayListItem();

            playlist.Add(item1);
            Assert.IsNull(player.GetCurrentItem());
        }
Exemple #30
0
 // constructor
 public PlayList()
 {
     this.head      = new PlayListItem();
     this.tail      = new PlayListItem();
     this.Curr      = new PlayListItem();
     this.head.Next = this.tail;
     this.head.Prev = null;
     this.tail.Next = null;
     this.tail.Prev = this.head;
     this.n         = 0;
 }
        /// <summary>
        /// Returns a playlistitem from a song
        ///
        /// Note: this method is available in MediaPortal 1.2 in
        /// MediaPortal.Music.Database.Song.ToPlayListItem()
        ///
        /// As it wasn't available in 1.1.3 this was copied to a private method
        /// TODO: Remove this once 1.2 has become stable and 1.1.3 is not needed anymore
        /// </summary>
        /// <param name="song">Song</param>
        /// <returns>Playlistitem from a song</returns>
        internal static PlayListItem ToPlayListItem(Song song)
        {
            PlayListItem pli = new PlayListItem();

            pli.Type        = PlayListItem.PlayListItemType.Audio;
            pli.FileName    = song.FileName;
            pli.Description = song.Title;
            pli.Duration    = song.Duration;
            pli.MusicTag    = song.ToMusicTag();

            return(pli);
        }
Exemple #32
0
 private void ShowMusics(Music[] musics)
 {
     for (int i = 0; i < musics.Length; i++)
     {
         var item = new PlayListItem(i);
         item.Music   = musics[i];
         item.Click  += MusicItem_Click;
         item.Play   += MusicItem_Click;
         item.Remove += MusicItem_Remove;
         stkList.Children.Add(item);
     }
 }
Exemple #33
0
        public override int RenderVisualization()
        {
            try
            {
                if (VisualizationWindow == null || !VisualizationWindow.Visible || _visParam.VisHandle == 0)
                {
                    return(0);
                }

                // Set Song information, so that the plugin can display it
                if (trackTag != null && Bass != null)
                {
                    _playlistPlayer = PlayListPlayer.SingletonPlayer;
                    PlayListItem curPlaylistItem = _playlistPlayer.GetCurrentItem();

                    _mediaInfo.Position    = (int)Bass.CurrentPosition;
                    _mediaInfo.Duration    = (int)Bass.Duration;
                    _mediaInfo.PlaylistLen = 1;
                    _mediaInfo.PlaylistPos = _playlistPlayer.CurrentPlaylistPos;
                }
                else
                {
                    _mediaInfo.Position    = 0;
                    _mediaInfo.Duration    = 0;
                    _mediaInfo.PlaylistLen = 0;
                    _mediaInfo.PlaylistPos = 0;
                }
                if (IsPreviewVisualization)
                {
                    _mediaInfo.SongTitle = "Mediaportal Preview";
                }
                BassVis.BASSVIS_SetInfo(_visParam, _mediaInfo);

                if (RenderStarted)
                {
                    return(1);
                }

                int stream = 0;

                if (Bass != null)
                {
                    stream = (int)Bass.GetCurrentVizStream();
                }

                BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play);
                RenderStarted = BassVis.BASSVIS_RenderChannel(_visParam, stream);
            }

            catch (Exception) {}

            return(1);
        }
        public void RaiseContentChangeWhenAddItemToPlayList()
        {
            var newItem          = new PlayListItem(new ImageId(30), "");
            var playListListener = MockRepository.GenerateMock <PlayListListener>();

            playListListener.Expect(l => l.ContentChanged(new PlayListContent(0, "", new [] { newItem })));
            var playList = new PlayList(new PlayListContent(0, "", new PlayListItem[0]), null);

            playList.AddListener(playListListener);

            playList.AddItem(newItem);
        }
        public void UplaodListViewOnlyForChnageInSelectedPlayList()
        {
            var playList1 = new PlayList(new PlayListContent(1, "name", new PlayListItem[0]), null);
            var playList2 = new PlayList(new PlayListContent(2, "name", new PlayListItem[0]), null);
            m_Model.SelectedPlayListChanged(playList1);
            m_Model.SelectedPlayListChanged(playList2);
            m_Model.SelectedPlayListChanged(playList1);
            var newItem = new PlayListItem(new ImageId(33), "trentatre");

            playList2.AddItem(newItem);

            Assert.That(GetPlayListItemsInListView(), Is.Empty);
        }
        public void AddNewItemToSelectedPlayList()
        {
            var playLists = new[]
                                {
                                    new PlayList(new PlayListContent(1, "name", new PlayListItem[0]), null),
                                    new PlayList(new PlayListContent(2, "name", new PlayListItem[0]), null),
                                };
            var newItem = new PlayListItem(new ImageId(33), "name33");
            m_Model.SelectedPlayListChanged(playLists[0]);

            m_Model.AddNewItem(newItem);

            Assert.That(playLists[0].Content, Is.EqualTo(new PlayListContent(1, "name", new[] { newItem })));
        }
        void Play_Step4(PlayListItem playItem, string lsUrl, bool goFullScreen)
        {

            OnlineVideos.MediaPortal1.Player.PlayerFactory factory = new OnlineVideos.MediaPortal1.Player.PlayerFactory(playItem.ForcedPlayer != null ? playItem.ForcedPlayer.Value : playItem.Util.Settings.Player, lsUrl);

            // check for valid url and cut off additional parameter
            if ((String.IsNullOrEmpty(lsUrl) ||
                !Helpers.UriUtils.IsValidUri((lsUrl.IndexOf(MPUrlSourceFilter.SimpleUrl.ParameterSeparator) > 0) ? lsUrl.Substring(0, lsUrl.IndexOf(MPUrlSourceFilter.SimpleUrl.ParameterSeparator)) : lsUrl))
                &&
                factory.PreparedPlayerType != PlayerType.Browser)
            {
                GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                if (dlg != null)
                {
                    dlg.Reset();
                    dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon"));
                    dlg.SetHeading(Translation.Instance.Error);
                    dlg.SetText(Translation.Instance.UnableToPlayVideo);
                    dlg.DoModal(GUIWindowManager.ActiveWindow);
                }
                return;
            }

            // stop player if currently playing some other video
            if (g_Player.Playing) g_Player.Stop();

            currentPlayingItem = null;

            if (factory.PreparedPlayerType != PlayerType.Internal)
            {
                // Websites will just go to play
                if (factory.PreparedPlayerType == PlayerType.Browser)
                {
                    (factory.PreparedPlayer as WebBrowserVideoPlayer).Initialise(playItem.Util);
                    factory.PreparedPlayer.Play(lsUrl);
                    return;
                }

                // external players can only be created on the main thread
                Play_Step5(playItem, lsUrl, goFullScreen, factory, true, true);
            }
            else
            {
                Log.Instance.Info("Preparing graph for playback of '{0}'", lsUrl);
                bool? prepareResult = ((OnlineVideosPlayer)factory.PreparedPlayer).PrepareGraph();
                switch (prepareResult)
                {
                    case true:// buffer in background
                        Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
                        {
                            try
                            {
                                Log.Instance.Info("Start prebuffering ...");
                                BufferingPlayerFactory = factory;
                                if (((OnlineVideosPlayer)factory.PreparedPlayer).BufferFile(playItem.Util))
                                {
                                    Log.Instance.Info("Prebuffering finished.");
                                    return true;
                                }
                                else
                                {
                                    Log.Instance.Info("Prebuffering failed.");
                                    return null;
                                }
                            }
                            finally
                            {
                                BufferingPlayerFactory = null;
                            }
                        },
                        delegate(bool success, object result)
                        {
                            // success false means BufferFile threw an exception that was shown to the user - pass it as showMessage
                            Play_Step5(playItem, lsUrl, goFullScreen, factory, result as bool?, success);
                        },
                        Translation.Instance.StartingPlayback, false);
                        break;
                    case false:// play without buffering in background
                        Play_Step5(playItem, lsUrl, goFullScreen, factory, prepareResult, true);
                        break;
                    default: // error building graph
                        GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                        if (dlg != null)
                        {
                            dlg.Reset();
                            dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon"));
                            dlg.SetHeading(Translation.Instance.Error);
                            dlg.SetText(Translation.Instance.UnableToPlayVideo);
                            dlg.DoModal(GUIWindowManager.ActiveWindow);
                        }
                        break;
                }
            }
        }
 private void Play_Step3(PlayListItem playItem, List<String> loUrlList, bool goFullScreen, bool skipPlaybackOptionsDialog)
 {
     // if multiple quality choices are available show a selection dialogue (also on playlist playback)
     string lsUrl = loUrlList[0];
     bool resolve = DisplayPlaybackOptions(playItem.Video, ref lsUrl, skipPlaybackOptionsDialog); // resolve only when any playbackoptions were set
     if (lsUrl == "-1") return; // the user did not chose an option but canceled the dialog
     if (resolve)
     {
         playItem.ChosenPlaybackOption = lsUrl;
         // display wait cursor as GetPlaybackOptionUrl might do webrequests when overridden
         Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
         {
             return playItem.Video.GetPlaybackOptionUrl(lsUrl);
         },
         delegate(bool success, object result)
         {
             if (success) Play_Step4(playItem, result as string, goFullScreen);
         }
         , Translation.Instance.GettingPlaybackUrlsForVideo, true);
     }
     else
     {
         Play_Step4(playItem, lsUrl, goFullScreen);
     }
 }
        private void Play_Step2(PlayListItem playItem, List<String> loUrlList, bool goFullScreen, bool skipPlaybackOptionsDialog)
        {

            if (playItem.Util.Settings.Player != PlayerType.Browser)
                Helpers.UriUtils.RemoveInvalidUrls(loUrlList);

            // if no valid urls were returned show error msg
            if (loUrlList == null || loUrlList.Count == 0)
            {
                GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                if (dlg != null)
                {
                    dlg.Reset();
                    dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon"));
                    dlg.SetHeading(Translation.Instance.Error);
                    dlg.SetText(Translation.Instance.UnableToPlayVideo);
                    dlg.DoModal(GUIWindowManager.ActiveWindow);
                }
                return;
            }
            // create playlist entries if more than one url
            if (loUrlList.Count > 1)
            {
                Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
                {
                    Player.PlayList playbackItems = new Player.PlayList();
                    foreach (string url in loUrlList)
                    {
                        VideoInfo vi = playItem.Video.CloneForPlaylist(url, url == loUrlList[0]);
                        string url_new = url;
                        if (url == loUrlList[0])
                        {
                            url_new = SelectedSite.GetPlaylistItemVideoUrl(vi, string.Empty, currentPlaylist != null && currentPlaylist.IsPlayAll);
                        }
                        PlayListItem pli = new PlayListItem(string.Format("{0} - {1} / {2}", playItem.Video.Title, (playbackItems.Count + 1).ToString(), loUrlList.Count), url_new);
                        pli.Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.VideoStream;
                        pli.Video = vi;
                        pli.Util = playItem.Util;
                        pli.ForcedPlayer = playItem.ForcedPlayer;
                        playbackItems.Add(pli);
                    }
                    if (currentPlaylist == null)
                    {
                        currentPlaylist = playbackItems;
                    }
                    else
                    {
                        int currentPlaylistIndex = currentPlayingItem != null ? currentPlaylist.IndexOf(currentPlayingItem) : 0;
                        currentPlaylist.InsertRange(currentPlaylistIndex, playbackItems);
                    }
                    // make the first item the current to be played now
                    playItem = playbackItems[0];
                    loUrlList = new List<string>(new string[] { playItem.FileName });
                    return null;
                },
                delegate(bool success, object result)
                {
                    if (success) Play_Step3(playItem, loUrlList, goFullScreen, skipPlaybackOptionsDialog);
                    else currentPlaylist = null;
                }
                , Translation.Instance.GettingPlaybackUrlsForVideo, true);
            }
            else
            {
                Play_Step3(playItem, loUrlList, goFullScreen, skipPlaybackOptionsDialog);
            }
        }
 private void Play_Step1(PlayListItem playItem, bool goFullScreen, bool skipPlaybackOptionsDialog = false)
 {
     if (!string.IsNullOrEmpty(playItem.FileName))
     {
         Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
         {
             return SelectedSite.GetPlaylistItemVideoUrl(playItem.Video, currentPlaylist[0].ChosenPlaybackOption, currentPlaylist.IsPlayAll);
         },
         delegate(bool success, object result)
         {
             if (success) Play_Step2(playItem, new List<String>() { result as string }, goFullScreen, skipPlaybackOptionsDialog);
             else if (currentPlaylist != null && currentPlaylist.Count > 1) PlayNextPlaylistItem();
         }
         , Translation.Instance.GettingPlaybackUrlsForVideo, true);
     }
     else
     {
         Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
         {
             return SelectedSite.GetMultipleVideoUrls(playItem.Video, currentPlaylist != null && currentPlaylist.Count > 1);
         },
         delegate(bool success, object result)
         {
             if (success) Play_Step2(playItem, result as List<String>, goFullScreen, skipPlaybackOptionsDialog);
             else if (currentPlaylist != null && currentPlaylist.Count > 1) PlayNextPlaylistItem();
         }
         , Translation.Instance.GettingPlaybackUrlsForVideo, true);
     }
 }
Exemple #41
0
        /// <summary>
        /// Handle keyboard/remote action
        /// </summary>
        /// <param name="action"></param>
        public override void OnAction(MediaPortal.GUI.Library.Action action)
        {
            MediaPortal.GUI.Library.Action.ActionType wID = action.wID;
              // Queue video to playlist
              if (wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_QUEUE_ITEM)
              {
            facadeLayout.SelectedListItemIndex = Player.playlistPlayer.CurrentItem;
            return;
              }
              // If on Track screen go back to artists screen
              if (wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU)
              {
            artistID = CurrentArtistId;
            // Go Back to last view
            _currentView = getPreviousView();
            // Have we backed out to the last screen, if so exit otherwise load the previous screen
            if (_currentView == MvView.None)
              base.OnAction(action);
            else
              loadCurrent();
              }
              else if (wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_CONTEXT_MENU)
              {
            string contextChoice = ShowContextMenu();
            if (contextChoice == Localization.AddToPlaylist)
            {
              //Add to playlist

              // If on a folder add all Videos for Artist
              if (facadeLayout.ListLayout.SelectedListItem.IsFolder)
              {
            _currArtist = DBArtistInfo.Get(facadeLayout.ListLayout.SelectedListItem.Label);
            var allTracksByArtist = DBTrackInfo.GetEntriesByArtist(_currArtist);
            AddToPlaylist(allTracksByArtist, false, mvCentralCore.Settings.ClearPlaylistOnAdd, mvCentralCore.Settings.GeneratedPlaylistAutoShuffle);
              }
              else
              {
            // Add video to playlist
            var playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL);
            var filename = facadeLayout.ListLayout.SelectedListItem.Label;
            var path = facadeLayout.ListLayout.SelectedListItem.Path;
            var video = (DBTrackInfo)facadeLayout.ListLayout.SelectedListItem.MusicTag;
            var p1 = new PlayListItem(video);
            p1.Track = video;
            playlist.Add(p1);
              }
            }
            else if (contextChoice == Localization.AddAllToPlaylist)
            {
              // Add all videos to the playlist

              var allTracks = DBTrackInfo.GetAll();
              AddToPlaylist(allTracks, false, mvCentralCore.Settings.ClearPlaylistOnAdd, mvCentralCore.Settings.GeneratedPlaylistAutoShuffle);
            }
            else if (contextChoice == Localization.AddToPlaylistNext)
            {
              // Add video as next playlist item

              addToPlaylistNext(facadeLayout.SelectedListItem);
            }
            else if (contextChoice == Localization.RefreshArtwork)
            {
              // Refresh the artwork

              if (facadeLayout.ListLayout.SelectedListItem.IsFolder)
              {
            _currArtist = DBArtistInfo.Get(facadeLayout.SelectedListItem.Label);
            GUIWaitCursor.Show();
            mvCentralCore.DataProviderManager.GetArt(_currArtist, false);
            GUIWaitCursor.Hide();
            facadeLayout.SelectedListItem.ThumbnailImage = _currArtist.ArtThumbFullPath;
            facadeLayout.SelectedListItem.RefreshCoverArt();
            facadeLayout.SelectedListItemIndex = facadeLayout.SelectedListItemIndex - 1;
            facadeLayout.SelectedListItemIndex = facadeLayout.SelectedListItemIndex + 1;
              }
              else
              {
            var video = (DBTrackInfo)facadeLayout.ListLayout.SelectedListItem.MusicTag;
            GUIWaitCursor.Show();
            mvCentralCore.DataProviderManager.GetArt(video, false);
            GUIWaitCursor.Hide();
            facadeLayout.SelectedListItem.ThumbnailImage = video.ArtFullPath;
            facadeLayout.SelectedListItem.RefreshCoverArt();
            facadeLayout.SelectedListItemIndex = facadeLayout.SelectedListItemIndex - 1;
            facadeLayout.SelectedListItemIndex = facadeLayout.SelectedListItemIndex + 1;
              }
            }
            else if (contextChoice == Localization.RateVid)
            {
              // Allow user rating of video

              OnSetRating(facadeLayout.SelectedListItemIndex);
            }
              }

              else
            base.OnAction(action);
        }
        void Play_Step5(PlayListItem playItem, string lsUrl, bool goFullScreen, OnlineVideos.MediaPortal1.Player.PlayerFactory factory, bool? factoryPrepareResult, bool showMessage)
        {
            if (factoryPrepareResult == null)
            {
                if (factory.PreparedPlayer is OnlineVideosPlayer && (factory.PreparedPlayer as OnlineVideosPlayer).BufferingStopped == true) showMessage = false;
                factory.PreparedPlayer.Dispose();
                if (showMessage)
                {
                    GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                    if (dlg != null)
                    {
                        dlg.Reset();
                        dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon"));
                        dlg.SetHeading(Translation.Instance.Error);
                        dlg.SetText(Translation.Instance.UnableToPlayVideo);
                        dlg.DoModal(GUIWindowManager.ActiveWindow);
                    }
                }
            }
            else
            {
                (factory.PreparedPlayer as OVSPLayer).GoFullscreen = goFullScreen;

                Uri subtitleUri = null;
                bool validUri = !String.IsNullOrEmpty(playItem.Video.SubtitleUrl) && Uri.TryCreate(playItem.Video.SubtitleUrl, UriKind.Absolute, out subtitleUri);

                if (!string.IsNullOrEmpty(playItem.Video.SubtitleText) || (validUri && !subtitleUri.IsFile))
                {
                    // download subtitle file before starting playback
                    Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
                    {
                        string subs = string.IsNullOrEmpty(playItem.Video.SubtitleText) ? WebCache.Instance.GetWebData(playItem.Video.SubtitleUrl) : playItem.Video.SubtitleText;
                        if (!string.IsNullOrEmpty(subs))
                        {
                            string subFile = Path.Combine(Path.GetTempPath(), "OnlineVideoSubtitles.txt");
                            File.WriteAllText(subFile, subs, System.Text.Encoding.UTF8);
                            (factory.PreparedPlayer as OVSPLayer).SubtitleFile = subFile;
                        }
                        return true;
                    },
                    delegate(bool success, object result)
                    {
                        Play_Step6(playItem, lsUrl, factory);
                    },
                    Translation.Instance.DownloadingSubtitle, true);
                }
                else
                {
                    if (validUri && subtitleUri.IsFile)
                        (factory.PreparedPlayer as OVSPLayer).SubtitleFile = subtitleUri.AbsolutePath;
                    Play_Step6(playItem, lsUrl, factory);
                }
            }
        }
Exemple #43
0
        /// <summary>
        /// Save the current playlist
        /// </summary>
        private void saveSmartDJPlaylist()
        {
            string playlistFileName = string.Empty;
              if (GetKeyboard(ref playlistFileName))
              {
            string playListPath = string.Empty;
            // Have we out own playlist folder configured
            if (!string.IsNullOrEmpty(mvCentralCore.Settings.PlayListFolder.Trim()))
              playListPath = mvCentralCore.Settings.PlayListFolder;
            else
            {
              // No, so use my videos location
              using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings())
              {
            playListPath = xmlreader.GetValueAsString("movies", "playlists", string.Empty);
            playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath);
              }

              playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath);
            }

            // check if Playlist folder exists, create it if not
            if (!Directory.Exists(playListPath))
            {
              try
              {
            Directory.CreateDirectory(playListPath);
              }
              catch (Exception e)
              {
            logger.Info("Error: Unable to create Playlist path: " + e.Message);
            return;
              }
            }

            string fullPlayListPath = Path.GetFileNameWithoutExtension(playlistFileName);

            fullPlayListPath += ".mvplaylist";
            if (playListPath.Length != 0)
            {
              fullPlayListPath = playListPath + @"\" + fullPlayListPath;
            }
            PlayList playlist = new PlayList();
            for (int i = 0; i < facadeLayout.Count; ++i)
            {
              GUIListItem listItem = facadeLayout[i];
              PlayListItem playListItem = new PlayListItem();
              DBTrackInfo mv = (DBTrackInfo)listItem.MusicTag;
              playListItem.Track = mv;
              playlist.Add(playListItem);
            }
            PlayListIO saver = new PlayListIO();
            saver.Save(playlist, fullPlayListPath);
              }
        }
Exemple #44
0
 /// <summary>
 /// Add selected item to end of Playlist
 /// </summary>
 /// <param name="listItem"></param>
 private void addToPlaylistNext(GUIListItem listItem)
 {
     PlayList playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL);
       PlayListItem item = new PlayListItem(listItem.TVTag as DBTrackInfo);
       playlist.Insert(item, Player.playlistPlayer.CurrentItem);
 }
Exemple #45
0
        private bool AddItem(string ID, string Title, string ChapterID, string File)
        {
            DBTrackInfo mv = DBTrackInfo.Get(Convert.ToInt16(ID));

            if (mv == null)
                return false;

            PlayListItem newItem = new PlayListItem(mv);
            newItem.FileName = mv.LocalMedia[0].File.FullName;
            playlist.Add(newItem);
            return true;
        }
		private static string GetSubtitleFile(PlayListItem playItem)
		{
			string subFile = null;

			Uri subtitleUri = null;
			bool validUri = !String.IsNullOrEmpty(playItem.Video.SubtitleUrl) && Uri.TryCreate(playItem.Video.SubtitleUrl, UriKind.Absolute, out subtitleUri);
			if (!string.IsNullOrEmpty(playItem.Video.SubtitleText) || (validUri && !subtitleUri.IsFile))
			{
				string subs = string.IsNullOrEmpty(playItem.Video.SubtitleText) ? WebCache.Instance.GetWebData(playItem.Video.SubtitleUrl) : playItem.Video.SubtitleText;
				if (!string.IsNullOrEmpty(subs))
				{
					subFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "OnlineVideoSubtitles.txt");
					System.IO.File.WriteAllText(subFile, subs, System.Text.Encoding.UTF8);
				}
			}
			else
			{
				if (validUri && subtitleUri.IsFile)
					subFile = subtitleUri.AbsolutePath;
			}

			return subFile;
		}
		private void Play_Step2(PlayListItem playItem, List<String> urlList, bool goFullScreen)
		{
			RemoveInvalidUrls(urlList);

			// if no valid urls were returned show error msg
			if (urlList == null || urlList.Count == 0) {
				notification.Show(Translation.Instance.Error, Translation.Instance.UnableToPlayVideo);
				return;
			}

			// create playlist entries if more than one url
			if (urlList.Count > 1)
			{
				PlayList playbackItems = new PlayList();
				foreach (string url in urlList)
				{
					VideoInfo vi = playItem.Video.CloneForPlaylist(url, url == urlList[0]);
					string url_new = url;
					if (url == urlList[0])
					{
						url_new = SelectedSite.GetPlaylistItemVideoUrl(vi, string.Empty, CurrentPlayList != null && CurrentPlayList.IsPlayAll);
					}
					playbackItems.Add(new PlayListItem(vi, playItem.Util)
					{
						FileName = url_new
					});
				}
				if (CurrentPlayList == null)
				{
					CurrentPlayList = playbackItems;
				}
				else
				{
					int currentPlaylistIndex = CurrentPlayListItem != null ? CurrentPlayList.IndexOf(CurrentPlayListItem) : 0;
					CurrentPlayList.InsertRange(currentPlaylistIndex, playbackItems);
				}
				// make the first item the current to be played now
				playItem = playbackItems[0];
				urlList = new List<string>(new string[] { playItem.FileName });
			}

			// play the first or only item
			string urlToPlay = urlList[0];
			if (playItem.Video.PlaybackOptions != null && playItem.Video.PlaybackOptions.Count > 0)
			{
				string choice = null;
				if (playItem.Video.PlaybackOptions.Count > 1)
				{
					PlaybackChoices dlg = new PlaybackChoices();
					dlg.Owner = this;
					dlg.lvChoices.ItemsSource = playItem.Video.PlaybackOptions.Keys;
					var preSelectedItem = playItem.Video.PlaybackOptions.FirstOrDefault(kvp => kvp.Value == urlToPlay);
					if (!string.IsNullOrEmpty(preSelectedItem.Key)) dlg.lvChoices.SelectedValue = preSelectedItem.Key;
					if (dlg.lvChoices.SelectedIndex < 0) dlg.lvChoices.SelectedIndex = 0;
					if (dlg.ShowDialog() == true) choice = dlg.lvChoices.SelectedItem.ToString();
				}
				else
				{
					choice = playItem.Video.PlaybackOptions.Keys.First();
				}

				if (choice != null)
				{
					playItem.ChosenPlaybackOption = choice;
                    Log.Info("Chosen quality: '{0}'", choice);
					waitCursor.Visibility = System.Windows.Visibility.Visible;
					Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
					{
						return playItem.Video.GetPlaybackOptionUrl(choice);
					},
					delegate(Gui2UtilConnector.ResultInfo resultInfo)
					{
						waitCursor.Visibility = System.Windows.Visibility.Hidden;
						if (ReactToResult(resultInfo, Translation.Instance.GettingPlaybackUrlsForVideo))
						{
							Play_Step3(playItem, resultInfo.ResultObject as string, goFullScreen);
						}
					}, true);
				}
			}
			else
			{
				Play_Step3(playItem, urlToPlay, goFullScreen);
			}
		}
        internal void SetGuiProperties_PlayingVideo(PlayListItem playItem)
        {
            // first reset our own properties
            GUIPropertyManager.SetProperty("#Play.Current.OnlineVideos.SiteIcon", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.OnlineVideos.SiteName", string.Empty);

            // start a thread that will set the properties in 2 seconds (otherwise MediaPortal core logic would overwrite them)
            if (playItem == null || playItem.Video == null) return;
            new System.Threading.Thread(delegate(object o)
            {
                try
                {
                    VideoInfo video = (o as PlayListItem).Video;
                    string alternativeTitle = (o as PlayListItem).Description;
                    Sites.SiteUtilBase site = (o as PlayListItem).Util;

                    System.Threading.Thread.Sleep(2000);

                    string quality = video.PlaybackOptions != null ? video.PlaybackOptions.FirstOrDefault(po => po.Value == (g_Player.Player as OVSPLayer).PlaybackUrl).Key : null;

                    string titleToShow = "";
                    if (!string.IsNullOrEmpty(alternativeTitle))
                        titleToShow = alternativeTitle;
                    else if (!string.IsNullOrEmpty(video.Title))
                        titleToShow = video.Title + (string.IsNullOrEmpty(quality) ? "" : " (" + quality + ")");

                    Log.Instance.Info("Setting Video Properties for '{0}'", titleToShow);

                    if (!string.IsNullOrEmpty(titleToShow)) GUIPropertyManager.SetProperty("#Play.Current.Title", titleToShow);
                    if (!string.IsNullOrEmpty(video.Description)) GUIPropertyManager.SetProperty("#Play.Current.Plot", video.Description);
                    if (!string.IsNullOrEmpty(video.ThumbnailImage)) GUIPropertyManager.SetProperty("#Play.Current.Thumb", video.ThumbnailImage);
                    if (!string.IsNullOrEmpty(video.Airdate)) GUIPropertyManager.SetProperty("#Play.Current.Year", video.Airdate);
                    else if (!string.IsNullOrEmpty(video.Length)) GUIPropertyManager.SetProperty("#Play.Current.Year", Helpers.TimeUtils.TimeFromSeconds(video.Length));

                    if (site != null)
                    {
                        GUIPropertyManager.SetProperty("#Play.Current.OnlineVideos.SiteIcon", SiteImageExistenceCache.GetImageForSite(site.Settings.Name, site.Settings.UtilName, "Icon"));
                        GUIPropertyManager.SetProperty("#Play.Current.OnlineVideos.SiteName", site.Settings.Name);
                    }
                }
                catch (Exception ex)
                {
                    Log.Instance.Warn("Error setting playing video properties: {0}", ex.ToString());
                }
            }) { IsBackground = true, Name = "OVPlaying" }.Start(playItem);

            TrackPlayback();
        }
        private void Play_Step6(PlayListItem playItem, string lsUrl, OnlineVideos.MediaPortal1.Player.PlayerFactory factory)
        {
            IPlayerFactory savedFactory = g_Player.Factory;
            g_Player.Factory = factory;
            try
            {
                if (factory.PreparedPlayer is OnlineVideosPlayer)
                    g_Player.Play("http://localhost/OnlineVideo.mp4", g_Player.MediaType.Video); // hack to get around the MP 1.3 Alpha bug with non http URLs
                else
                    g_Player.Play(lsUrl, g_Player.MediaType.Video);
            }
            catch (Exception ex) // since many plugins attach to the g_Player.PlayBackStarted event, this might throw unexpected errors
            {
                Log.Instance.Warn(ex.ToString());
            }
            g_Player.Factory = savedFactory;

            if (g_Player.Player != null && g_Player.HasVideo)
            {
                if (!string.IsNullOrEmpty(playItem.Video.StartTime))
                {
                    Log.Instance.Info("Found starttime: {0}", playItem.Video.StartTime);
                    double seconds = Helpers.TimeUtils.SecondsFromTime(playItem.Video.StartTime);
                    if (seconds > 0.0d)
                    {
                        Log.Instance.Info("SeekingAbsolute: {0}", seconds);
                        g_Player.SeekAbsolute(seconds);
                    }
                }
                playItem.FileName = lsUrl;
                currentPlayingItem = playItem;
                SetGuiProperties_PlayingVideo(playItem);
            }
        }
        /// <summary>        
        /// Updates the movie metadata on the playback screen (for when the user clicks info). 
        /// The delay is neccesary because Player tries to use metadata from the MyVideos database.
        /// We want to update this after that happens so the correct info is there.       
        /// </summary>
        /// <param name="item">Playlist item</param>
        /// <param name="clear">Clears the properties instead of filling them if True</param>
        private void SetProperties(PlayListItem item, bool clear)
        {
            // List of Play properities that can be overidden
              //#Play.Current.Director
              //#Play.Current.Genre
              //#Play.Current.Cast
              //#Play.Current.DVDLabel
              //#Play.Current.IMDBNumber
              //#Play.Current.File
              //#Play.Current.Plot
              //#Play.Current.PlotOutline
              //#Play.Current.UserReview
              //#Play.Current.Rating
              //#Play.Current.TagLine
              //#Play.Current.Votes
              //#Play.Current.Credits
              //#Play.Current.Thumb
              //#Play.Current.Title
              //#Play.Current.Year
              //#Play.Current.Runtime
              //#Play.Current.MPAARating

              logger.Debug("******************************************************");

              if (clear)
            logger.Debug("************* CLEAR Play Properities event *************");
              else
            logger.Debug("************** SET Play Properities event **************");

              logger.Debug("******************************************************");

              if (item == null)
            return;

              // If set have been told to clear the properties but we are playing a video, exit out - this happens because we get the stop play event after the start play event for the next video.
              if (clear && mvPlayer.Playing)
              {
            logger.Debug("************** Abort SET Play Properities event, there is a Video Playing **************");
            return;
              }
              logger.Debug("Set #mvCentral.Play.Started = false");
              GUIPropertyManager.SetProperty("#mvCentral.Play.Started", "false");

              string title = string.Empty;
              string osdImage = string.Empty;
              string osdVideoImage = string.Empty;
              string osdArtistImage = string.Empty;
              string album = string.Empty;
              string genre = string.Empty;
              string isWatched = "no";
              string userTrackRating = string.Empty;

              DBArtistInfo artistInfo = null;
              DBTrackInfo trackInfo = null;

              if (!clear)
              {
            // Only sleep if setting the props
            Thread.Sleep(mvCentralCore.Settings.PlayProperitiesSetDelay);

            trackInfo = (DBTrackInfo)item.Track;
            artistInfo = DBArtistInfo.Get(trackInfo);
            // may not have an album
            if (trackInfo.AlbumInfo.Count > 0)
              album = trackInfo.AlbumInfo[0].Album;

            title = trackInfo.Track;

            if (System.IO.File.Exists(artistInfo.ArtFullPath))
              osdImage = artistInfo.ArtFullPath;

            if (System.IO.File.Exists(trackInfo.ArtFullPath))
              osdVideoImage = trackInfo.ArtFullPath;

            if (artistInfo.Genre.Trim().Length > 0)
              genre = artistInfo.Genre;

            // Has this video been watched
            DBUserMusicVideoSettings userSettings = trackInfo.ActiveUserSettings;
            if (userSettings.WatchedCount > 0)
              isWatched = "yes";
            userTrackRating = userSettings.UserRating.ToString();

            // If not rating set to "0"
            if (string.IsNullOrEmpty(userTrackRating.Trim()))
              userTrackRating = "0";

              }
              // Std Play Properities
              GUIPropertyManager.SetProperty("#Play.Current.Title", clear ? string.Empty : title);
              GUIPropertyManager.SetProperty("#Play.Current.Thumb", clear ? string.Empty : osdImage);
              GUIPropertyManager.SetProperty("#Play.Current.Genre", clear ? string.Empty : genre);
              GUIPropertyManager.SetProperty("#Play.Current.Runtime", clear ? string.Empty : trackDuration(trackInfo.PlayTime));
              GUIPropertyManager.SetProperty("#Play.Current.Rating", clear ? string.Empty : userTrackRating);
              GUIPropertyManager.SetProperty("#Play.Current.Plot", clear ? string.Empty : mvCentralUtils.bioNoiseFilter(trackInfo.bioContent));
              GUIPropertyManager.SetProperty("#Play.Current.IsWatched", isWatched);

              // mvCentral Play Properities
              GUIPropertyManager.SetProperty("#Play.Current.mvArtist", clear ? string.Empty : artistInfo.Artist);
              GUIPropertyManager.SetProperty("#Play.Current.mvAlbum", clear ? string.Empty : album);
              GUIPropertyManager.SetProperty("#Play.Current.mvVideo", clear ? string.Empty : title);
              GUIPropertyManager.SetProperty("#Play.Current.Video.Thumb", clear ? string.Empty : osdVideoImage);
              GUIPropertyManager.SetProperty("#mvCentral.isPlaying", clear ? "false" : "true");
              // Video Properities
              try
              {
            DBLocalMedia mediaInfo = (DBLocalMedia)trackInfo.LocalMedia[0];
            GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", mediaInfo.VideoAspectRatio);
            GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", mediaInfo.VideoCodec);
            GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", mediaInfo.VideoResolution);
            GUIPropertyManager.SetProperty("#mvCentral.Current.videowidth", mediaInfo.VideoWidth.ToString());
            GUIPropertyManager.SetProperty("#mvCentral.Current.videoheight", mediaInfo.VideoHeight.ToString());
            GUIPropertyManager.SetProperty("#mvCentral.Current.videoframerate", mediaInfo.VideoFrameRate.ToString());
            GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", mediaInfo.AudioCodec);
            GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", mediaInfo.AudioChannels);

            if (!clear)
            {
              logger.Debug("**** Setting Play Properities for {0} - {1} (Item:{2}) ****", artistInfo.Artist, title, _currentItem);
              logger.Debug(" ");
              logger.Debug("#Play.Current.Title {0}", title);
              logger.Debug("#Play.Current.Thumb {0}", osdImage);
              logger.Debug("#Play.Current.Genre {0}", genre);
              logger.Debug("#Play.Current.Runtime {0}", trackDuration(trackInfo.PlayTime));
              logger.Debug("#Play.Current.Rating {0}", userTrackRating);
              logger.Debug("#Play.Current.Plot {0}", trackInfo.bioContent);
              logger.Debug("#Play.Current.IsWatched {0}", isWatched);
              logger.Debug("#Play.Current.mvArtist {0}", artistInfo.Artist);
              logger.Debug("#Play.Current.mvAlbum {0}", album);
              logger.Debug("#Play.Current.mvVideo {0}", title);
              logger.Debug("#Play.Current.Video.Thumb {0}", osdVideoImage);
              logger.Debug("#mvCentral.isPlaying {0}", clear ? "false" : "true");
              logger.Debug("#Play.Current.AspectRatio {0}", mediaInfo.VideoAspectRatio);
              logger.Debug("#Play.Current.VideoCodec.Texture {0}", mediaInfo.VideoCodec);
              logger.Debug("#Play.Current.VideoResolution {0}", mediaInfo.VideoResolution);
              logger.Debug("#mvCentral.Current.videowidth {0}", mediaInfo.VideoWidth.ToString());
              logger.Debug("#mvCentral.Current.videoheight {0}", mediaInfo.VideoHeight.ToString());
              logger.Debug("#mvCentral.Current.videoframerate {0}", mediaInfo.VideoFrameRate.ToString());
              logger.Debug("#Play.Current.AudioCodec.Texture {0}", mediaInfo.AudioCodec);
              logger.Debug("#Play.Current.AudioChannels {0}", mediaInfo.AudioChannels);
              logger.Debug(" ");
            }
              }
              catch
              {
            GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", string.Empty);
            GUIPropertyManager.SetProperty("#mvCentral.Current.videowidth", string.Empty);
            GUIPropertyManager.SetProperty("#mvCentral.Current.videoheight", string.Empty);
            GUIPropertyManager.SetProperty("#mvCentral.Current.videoframerate", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", string.Empty);
              }

              // Set 5sec timer to clear the Play Started Property
              if (!clear)
              {
            // Only set  #mvCentral.Play.Started and clear timer if On Video Start Info is enabled
            if (mvCentralCore.Settings.EnableVideoStartInfo)
            {
              timerClearProperty.Elapsed += new ElapsedEventHandler(timerClearProperty_Elapsed);
              timerClearProperty.Enabled = true;
              logger.Debug("Set #mvCentral.Play.Started = true");
              GUIPropertyManager.SetProperty("#mvCentral.Play.Started", "true");
            }
            // Grab the next item
            PlayListItem nextItem = null;
            nextItem = GetNextItem();
            // If we have one lets set the next properties
            if (nextItem != null)
              SetNextItemProperties(nextItem, clear);
              }

              logger.Debug("**** On exit from setProperities ****");
              logger.Debug("Set #mvCentral.Play.Started : {0}", GUIPropertyManager.GetProperty("#mvCentral.Play.Started"));
              logger.Debug("Set #mvCentral.isPlaying    : {0}", GUIPropertyManager.GetProperty("#mvCentral.isPlaying"));
        }
		private void Play_Step1(PlayListItem playItem, bool goFullScreen)
		{
			if (!string.IsNullOrEmpty(playItem.FileName))
			{
				Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
				{
					return SelectedSite.GetPlaylistItemVideoUrl(playItem.Video, CurrentPlayList[0].ChosenPlaybackOption, CurrentPlayList.IsPlayAll);
				},
				delegate(Gui2UtilConnector.ResultInfo resultInfo)
				{
					waitCursor.Visibility = System.Windows.Visibility.Hidden;
					if (ReactToResult(resultInfo, Translation.Instance.GettingPlaybackUrlsForVideo))
						Play_Step2(playItem, new List<String>() { resultInfo.ResultObject as string }, goFullScreen);
					else if (CurrentPlayList != null && CurrentPlayList.Count > 1) 
						PlayNextPlaylistItem();
				}
				, true);
			}
			else
			{
                Log.Info("Going to play: '{0}'", playItem.Video.Title);
				Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
				{
					return SelectedSite.GetMultipleVideoUrls(playItem.Video, CurrentPlayList != null && CurrentPlayList.Count > 1);
				},
				delegate(Gui2UtilConnector.ResultInfo resultInfo)
				{
					waitCursor.Visibility = System.Windows.Visibility.Hidden;
					if (ReactToResult(resultInfo, Translation.Instance.GettingPlaybackUrlsForVideo))
						Play_Step2(playItem, resultInfo.ResultObject as List<String>, goFullScreen);
					else if (CurrentPlayList != null && CurrentPlayList.Count > 1) 
						PlayNextPlaylistItem();
				}
				, true);
			}
		}
 void ScrobbleSend(PlayListItem item)
 {
     DBArtistInfo artistInfo = null;
       DBTrackInfo trackInfo = null;
       trackInfo = item.Track;
       artistInfo = DBArtistInfo.Get(trackInfo);
       try
       {
     TimeSpan tt = TimeSpan.Parse(trackInfo.PlayTime);
     logger.Debug("Sending Scrobble info {0} - {1} ({2})", artistInfo.Artist, trackInfo.Track, tt.TotalSeconds.ToString());
     LastFMProfile.NowPlaying(artistInfo.Artist, trackInfo.Track, (int)tt.TotalSeconds);
       }
       catch
       {
     logger.Debug("***** Invalid track time - will not submit to Last.FM");
       }
 }
		void Play_Step3(PlayListItem playItem, string urlToPlay, bool goFullScreen)
		{
            // check for valid url and cut off additional parameter
            if (String.IsNullOrEmpty(urlToPlay) ||
				!UriUtils.IsValidUri((urlToPlay.IndexOf(OnlineVideos.MPUrlSourceFilter.SimpleUrl.ParameterSeparator) > 0) ? urlToPlay.Substring(0, urlToPlay.IndexOf(OnlineVideos.MPUrlSourceFilter.SimpleUrl.ParameterSeparator)) : urlToPlay))
			{
				notification.Show(Translation.Instance.Error, Translation.Instance.UnableToPlayVideo);
				return;
			}

            // decode and make an url valid for our filter
            var uri = new Uri(urlToPlay);
            string protocol = uri.Scheme.Substring(0, Math.Min(uri.Scheme.Length, 4));
            if (protocol == "http" ||protocol == "rtmp") uri = new Uri(UrlBuilder.GetFilterUrl(playItem.Util, urlToPlay));

			// Play
			CurrentPlayListItem = null;
            Log.Info("Starting Playback: '{0}'", uri);
			mediaPlayer.SubtitleFilePath = GetSubtitleFile(playItem);
            mediaPlayer.Source = uri;
			CurrentPlayListItem = playItem;
		}
        private void OnSavePlayList()
        {
            currentSelectedItem = m_Facade.SelectedListItemIndex;
            string playlistFileName = string.Empty;
            if (GetKeyboard(ref playlistFileName))
            {
                string playListPath = string.Empty;
                playListPath = DBOption.GetOptions(DBOption.cPlaylistPath);
                playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath);

                // check if Playlist folder exists, create it if not
                if (!Directory.Exists(playListPath)){
                    try {
                        Directory.CreateDirectory(playListPath);
                    }
                    catch (Exception e){
                        MPTVSeriesLog.Write("Error: Unable to create Playlist path: " + e.Message);
                        return;
                    }
                }

                string fullPlayListPath = Path.GetFileNameWithoutExtension(playlistFileName);

                fullPlayListPath += ".tvsplaylist";
                if (playListPath.Length != 0)
                {
                  fullPlayListPath = playListPath + @"\" + fullPlayListPath;
                }
                PlayList playlist = new PlayList();
                for (int i = 0; i < m_Facade.Count; ++i)
                {
                    GUIListItem listItem = m_Facade[i];
                    PlayListItem playListItem = new PlayListItem();
                    playListItem.Episode = listItem.TVTag as DBEpisode;
                    playlist.Add(playListItem);
                }
                PlayListIO saver = new PlayListIO();
                saver.Save(playlist, fullPlayListPath);
            }
        }
 void ScrobbleSubmit(PlayListItem item)
 {
     DBArtistInfo artistInfo = null;
       DBTrackInfo trackInfo = null;
       trackInfo = item.Track;
       artistInfo = DBArtistInfo.Get(trackInfo);
       TimeSpan tt = TimeSpan.Parse(trackInfo.PlayTime);
       logger.Debug("Submit Track to Last.FM {0} - {1} (2}", artistInfo.Artist, trackInfo.Track, tt.Seconds);
       LastFMProfile.Submit(artistInfo.Artist, trackInfo.Track, tt.Seconds);
 }
        /// <summary>
        /// Set the next item properities
        /// </summary>
        /// <param name="item"></param>
        /// <param name="clear"></param>
        void SetNextItemProperties(PlayListItem item, bool clear)
        {
            // List of Play properities that can be overidden
              //#Play.Next.Director
              //#Play.Next.Genre
              //#Play.Next.Cast
              //#Play.Next.DVDLabel
              //#Play.Next.IMDBNumber
              //#Play.Next.File
              //#Play.Next.Plot
              //#Play.Next.PlotOutline
              //#Play.Next.UserReview
              //#Play.Next.Rating
              //#Play.Next.TagLine
              //#Play.Next.Votes
              //#Play.Next.Credits
              //#Play.Next.Thumb
              //#Play.Next.Title
              //#Play.Next.Year
              //#Play.Next.Runtime
              //#Play.Next.MPAARating

              // Exit if we do not have a valid item
              if (item == null)
            return;

              logger.Debug("******************************************************");

              if (clear)
            logger.Debug("************* CLEAR Next Properities event *************");
              else
            logger.Debug("************** SET Next Properities event **************");

              logger.Debug("******************************************************");

              string title = string.Empty;
              string osdImage = string.Empty;
              string osdVideoImage = string.Empty;
              string osdArtistImage = string.Empty;
              string album = string.Empty;
              string genre = string.Empty;
              string isWatched = "no";
              string userTrackRating = string.Empty;

              DBArtistInfo artistInfo = null;
              DBTrackInfo trackInfo = null;

              if (!clear)
              {
            trackInfo = (DBTrackInfo)item.Track;
            artistInfo = DBArtistInfo.Get(trackInfo);
            // may not have an album
            if (trackInfo.AlbumInfo.Count > 0)
              album = trackInfo.AlbumInfo[0].Album;

            title = trackInfo.Track;

            if (System.IO.File.Exists(artistInfo.ArtFullPath))
              osdImage = artistInfo.ArtFullPath;

            if (System.IO.File.Exists(trackInfo.ArtFullPath))
              osdVideoImage = trackInfo.ArtFullPath;

            if (artistInfo.Genre.Trim().Length > 0)
              genre = artistInfo.Genre;

            // Has this video been watched
            DBUserMusicVideoSettings userSettings = trackInfo.ActiveUserSettings;
            if (userSettings.WatchedCount > 0)
              isWatched = "yes";
            userTrackRating = userSettings.UserRating.ToString();
            if (string.IsNullOrEmpty(userTrackRating.Trim()))
              userTrackRating = "0";

              }
              // Std Play Properities
              GUIPropertyManager.SetProperty("#Play.Next.Title", clear ? string.Empty : title);
              GUIPropertyManager.SetProperty("#Play.Next.Thumb", clear ? string.Empty : osdImage);
              GUIPropertyManager.SetProperty("#Play.Next.Genre", clear ? string.Empty : genre);
              GUIPropertyManager.SetProperty("#Play.Next.Runtime", clear ? string.Empty : trackDuration(trackInfo.PlayTime));
              GUIPropertyManager.SetProperty("#Play.Next.Rating", clear ? string.Empty : userTrackRating);
              GUIPropertyManager.SetProperty("#Play.Next.Plot", clear ? string.Empty : mvCentralUtils.bioNoiseFilter(trackInfo.bioContent));
              GUIPropertyManager.SetProperty("#Play.Next.IsWatched", isWatched);

              // mvCentral Play Properities
              GUIPropertyManager.SetProperty("#Play.Next.mvArtist", clear ? string.Empty : artistInfo.Artist);
              GUIPropertyManager.SetProperty("#Play.Next.mvAlbum", clear ? string.Empty : album);
              GUIPropertyManager.SetProperty("#Play.Next.mvVideo", clear ? string.Empty : title);
              GUIPropertyManager.SetProperty("#Play.Next.Video.Thumb", clear ? string.Empty : osdVideoImage);
              // Video Properities
              try
              {
            DBLocalMedia mediaInfo = (DBLocalMedia)trackInfo.LocalMedia[0];
            GUIPropertyManager.SetProperty("#Play.Next.AspectRatio", mediaInfo.VideoAspectRatio);
            GUIPropertyManager.SetProperty("#Play.Next.VideoCodec.Texture", mediaInfo.VideoCodec);
            GUIPropertyManager.SetProperty("#Play.Next.VideoResolution", mediaInfo.VideoResolution);
            GUIPropertyManager.SetProperty("#mvCentral.Next.videowidth", mediaInfo.VideoWidth.ToString());
            GUIPropertyManager.SetProperty("#mvCentral.Next.videoheight", mediaInfo.VideoHeight.ToString());
            GUIPropertyManager.SetProperty("#mvCentral.Next.videoframerate", mediaInfo.VideoFrameRate.ToString());
            GUIPropertyManager.SetProperty("#Play.Next.AudioCodec.Texture", mediaInfo.AudioCodec);
            GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", mediaInfo.AudioChannels);

            if (!clear)
            {
              logger.Debug("**** Setting Next Properities for {0} - {1) ****", artistInfo.Artist, title);
              logger.Debug(" ");
              logger.Debug("#Play.Next.Title {0}", title);
              logger.Debug("#Play.Next.Thumb {0}", osdImage);
              logger.Debug("#Play.Next.Genre {0}", genre);
              logger.Debug("#Play.Next.Runtime {0}", trackDuration(trackInfo.PlayTime));
              logger.Debug("#Play.Next.Rating {0}", userTrackRating);
              logger.Debug("#Play.Next.Plot {0}", trackInfo.bioContent);
              logger.Debug("#Play.Next.IsWatched {0}", isWatched);
              logger.Debug("#Play.Next.mvArtist {0}", artistInfo.Artist);
              logger.Debug("#Play.Next.mvAlbum {0}", album);
              logger.Debug("#Play.Next.mvVideo {0}", title);
              logger.Debug("#Play.Next.Video.Thumb {0}", osdVideoImage);
              logger.Debug("#mvCentral.isPlaying {0}", clear ? "false" : "true");
              logger.Debug("#Play.Next.AspectRatio {0}", mediaInfo.VideoAspectRatio);
              logger.Debug("#Play.Next.VideoCodec.Texture {0}", mediaInfo.VideoCodec);
              logger.Debug("#Play.Next.VideoResolution {0}", mediaInfo.VideoResolution);
              logger.Debug("#mvCentral.Next.videowidth {0}", mediaInfo.VideoWidth.ToString());
              logger.Debug("#mvCentral.Next.videoheight {0}", mediaInfo.VideoHeight.ToString());
              logger.Debug("#mvCentral.Next.videoframerate {0}", mediaInfo.VideoFrameRate.ToString());
              logger.Debug("#Play.Next.AudioCodec.Texture {0}", mediaInfo.AudioCodec);
              logger.Debug("#Play.Next.AudioChannels {0}", mediaInfo.AudioChannels);
              logger.Debug(" ");
            }
              }
              catch
              {
            GUIPropertyManager.SetProperty("#Play.Next.AspectRatio", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Next.VideoCodec.Texture", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Next.VideoResolution", string.Empty);
            GUIPropertyManager.SetProperty("#mvCentral.Next.videowidth", string.Empty);
            GUIPropertyManager.SetProperty("#mvCentral.Next.videoheight", string.Empty);
            GUIPropertyManager.SetProperty("#mvCentral.Next.videoframerate", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Next.AudioCodec.Texture", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Next.AudioChannels", string.Empty);
              }
        }
Exemple #57
0
        /// <summary>        
        /// Updates the movie metadata on the playback screen (for when the user clicks info). 
        /// The delay is neccesary because Player tries to use metadata from the MyVideos database.
        /// We want to update this after that happens so the correct info is there.       
        /// </summary>
        /// <param name="item">Playlist item</param>
        /// <param name="clear">Clears the properties instead of filling them if True</param>
        private void SetProperties(PlayListItem item, bool clear)
        {
            if (item == null) return;

            string title = string.Empty;
            DBSeries series = null;
            DBSeason season = null;

            if (!clear)
            {
                title = string.Format("{0} - {1}x{2} - {3}", item.SeriesName, item.SeasonIndex, item.EpisodeIndex, item.EpisodeName);
                series = Helper.getCorrespondingSeries(item.Episode[DBEpisode.cSeriesID]);
                season = Helper.getCorrespondingSeason(item.Episode[DBEpisode.cSeriesID], int.Parse(item.SeasonIndex));
            }

            // Show Plot in OSD or Hide Spoilers (note: FieldGetter takes care of that)
            GUIPropertyManager.SetProperty("#Play.Current.Plot", clear ? " " : FieldGetter.resolveDynString(TVSeriesPlugin.m_sFormatEpisodeMain, item.Episode));

            // Show Episode Thumbnail or Series Poster if Hide Spoilers is enabled
            string osdImage = string.Empty;
            if (!clear)
            {
                foreach (KeyValuePair<string, string> kvp in SkinSettings.VideoOSDImages)
                {
                    switch (kvp.Key)
                    {
                        case "episode":
                            osdImage = ImageAllocator.GetEpisodeImage(item.Episode);
                            break;
                        case "season":
                            osdImage = season.Banner;
                            break;
                        case "series":
                            osdImage = series.Poster;
                            break;
                        case "custom":
                            string value = replaceDynamicFields(kvp.Value, item.Episode);
                            string file = Helper.getCleanAbsolutePath(value);
                            if (System.IO.File.Exists(file))
                                osdImage = file;
                            break;
                    }

                    osdImage = osdImage.Trim();
                    if (string.IsNullOrEmpty(osdImage)) continue;
                    else break;
                }
            }
            GUIPropertyManager.SetProperty("#Play.Current.Thumb", clear ? " " : osdImage);

            foreach (KeyValuePair<string, string> kvp in SkinSettings.VideoPlayImages)
            {
                if (!clear)
                {
                    string value = replaceDynamicFields(kvp.Value, item.Episode);
                    string file = Helper.getCleanAbsolutePath(value);
                    if (System.IO.File.Exists(file))
                    {
                        MPTVSeriesLog.Write(string.Format("Setting play image {0} for property {1}", file, kvp.Key), MPTVSeriesLog.LogLevel.Debug);
                        GUIPropertyManager.SetProperty(kvp.Key, clear ? " " : file);
                    }
                }
                else
                {
                    MPTVSeriesLog.Write(string.Format("Clearing play image for property {0}", kvp.Key), MPTVSeriesLog.LogLevel.Debug);
                    GUIPropertyManager.SetProperty(kvp.Key, " ");
                }
            }

            GUIPropertyManager.SetProperty("#Play.Current.Title", clear ? "" : title);
            GUIPropertyManager.SetProperty("#Play.Current.Year", clear ? "" : FieldGetter.resolveDynString("<" + DBEpisode.cOutName + "." + DBOnlineEpisode.cFirstAired + ">", item.Episode, false));
            GUIPropertyManager.SetProperty("#Play.Current.Genre", clear ? "" : FieldGetter.resolveDynString(TVSeriesPlugin.m_sFormatEpisodeSubtitle, item.Episode));
        }
        void Play_Step5(PlayListItem playItem, string lsUrl, bool goFullScreen, OnlineVideos.MediaPortal1.Player.PlayerFactory factory, bool? factoryPrepareResult, bool showMessage)
        {
            if (factoryPrepareResult == null)
            {
                if (factory.PreparedPlayer is OnlineVideosPlayer && (factory.PreparedPlayer as OnlineVideosPlayer).BufferingStopped == true) showMessage = false;
                factory.PreparedPlayer.Dispose();
                if (showMessage)
                {
                    DisplayUnableToPlayDialog();
                }
            }
            else
            {
                (factory.PreparedPlayer as OVSPLayer).GoFullscreen = goFullScreen;

                Uri subtitleUri = null;
                bool validUri = !String.IsNullOrEmpty(playItem.Video.SubtitleUrl) && Uri.TryCreate(playItem.Video.SubtitleUrl, UriKind.Absolute, out subtitleUri);

                if (!string.IsNullOrEmpty(playItem.Video.SubtitleText) || (validUri && !subtitleUri.IsFile))
                {
                    // download subtitle file before starting playback
                    Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
                    {
                        string subs = string.IsNullOrEmpty(playItem.Video.SubtitleText) ? WebCache.Instance.GetWebData(playItem.Video.SubtitleUrl) : playItem.Video.SubtitleText;
                        if (!string.IsNullOrEmpty(subs))
                        {
                            string subFile = Path.Combine(Path.GetTempPath(), "OnlineVideoSubtitles.txt");
                            File.WriteAllText(subFile, subs, System.Text.Encoding.UTF8);
                            (factory.PreparedPlayer as OVSPLayer).SubtitleFile = subFile;
                        }
                        return true;
                    },
                    delegate(bool success, object result)
                    {
                        Play_Step6(playItem, lsUrl, factory);
                    },
                    Translation.Instance.DownloadingSubtitle, true);
                }
                else
                {
                    if (validUri && subtitleUri.IsFile)
                        (factory.PreparedPlayer as OVSPLayer).SubtitleFile = subtitleUri.AbsolutePath;
                    Play_Step6(playItem, lsUrl, factory);
                }
            }
        }