Exemplo n.º 1
0
 public GUITVSeriesPlayList()
 {
     GetID          = (int)Window.WINDOW_VIDEO_PLAYLIST;
     playlistPlayer = PlayListPlayer.SingletonPlayer;
     m_directory.AddDrives();
     m_directory.SetExtensions(Utils.VideoExtensions);
     m_directory.AddExtension(".tvsplaylist");
 }
Exemplo n.º 2
0
        /// <summary>
        /// Play all episodes of a series
        /// </summary>
        /// <param name="seriesId">ID of a series</param>
        /// <param name="onlyUnwatched">Play only unwatched episodes</param>
        /// <param name="autostart">If yes, automatically starts playback with the first episode</param>
        /// <param name="startIndex">Index of the item with which playback should start</param>
        /// <param name="switchToPlaylistView">If yes the playlistview will be shown</param>
        public static void PlaySeries(int seriesId, bool autostart, int startIndex, bool onlyUnwatched, bool switchToPlaylistView)
        {
            if (GUIGraphicsContext.form.InvokeRequired)
            {
                PlaySeriesAsyncDelegate d = new PlaySeriesAsyncDelegate(PlaySeries);
                GUIGraphicsContext.form.Invoke(d, new object[] { seriesId, autostart, startIndex, onlyUnwatched, switchToPlaylistView });
                return;
            }

            List<DBEpisode> episodes = DBEpisode.Get(seriesId);
            if (episodes == null || episodes.Count == 0) return;

            // filter out anything we can't play
            episodes.RemoveAll(e => string.IsNullOrEmpty(e[DBEpisode.cFilename]));

            // filter out watched episodes
            if (onlyUnwatched)
            {
                episodes.RemoveAll(e => e[DBOnlineEpisode.cWatched] != 0);
            }
            if (episodes.Count == 0) return;

            // Sort episodes and add them to the MP-TVSeries playlist player
            // Setup playlist player
            if (playlistPlayer == null)
            {
                playlistPlayer = PlayListPlayer.SingletonPlayer;
                playlistPlayer.PlaylistAutoPlay = true;
                playlistPlayer.RepeatPlaylist = DBOption.GetOptions(DBOption.cRepeatPlaylist);
            }

            playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Clear();
            episodes.Sort();

            foreach (DBEpisode episode in episodes)
            {
                PlayListItem playlistItem = new PlayListItem(episode);
                playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Add(playlistItem);
            }

            //automatically start playing the playlist
            if (autostart)
            {
                // and activate the playlist window if its not activated yet
                if (switchToPlaylistView)
                {
                    GUIWindowManager.ActivateWindow(GUITVSeriesPlayList.GetWindowID);
                }

                playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_TVSERIES;
                playlistPlayer.Reset();
                playlistPlayer.Play(0);
            }
        }
Exemplo n.º 3
0
        protected void LoadPlayList(string strPlayList)
        {
            IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);
            if (loader == null)
                return;
            PlayList playlist = new PlayList();

            if (!loader.Load(playlist, strPlayList))
            {
                ShowDialogOk(Translation.Playlist, new string[] { GUILocalizeStrings.Get(477) });
                return;
            }

            if (_playlistPlayer == null)
            {
                _playlistPlayer = PlayListPlayer.SingletonPlayer;
                _playlistPlayer.PlaylistAutoPlay = DBOption.GetOptions(DBOption.cPlaylistAutoPlay);
                _playlistPlayer.RepeatPlaylist = DBOption.GetOptions(DBOption.cRepeatPlaylist);
            }
            _playlistPlayer.CurrentPlaylistName = System.IO.Path.GetFileNameWithoutExtension(strPlayList);

            if (playlist.Count == 1 && _playlistPlayer.PlaylistAutoPlay)
            {
                // If the file is an image file, it should be mounted before playing
                string filename = playlist[0].FileName;
                if (Helper.IsImageFile(filename))
                {
                    if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, filename))
                    {
                        return;
                    }
                }

                MPTVSeriesLog.Write(string.Format("GUITVSeriesPlaylist: play single playlist item - {0}", playlist[0].FileName));
                if (g_Player.Play(filename))
                {
                    if (MediaPortal.Util.Utils.IsVideo(filename))
                    {
                        g_Player.ShowFullScreenWindow();
                    }
                }
                return;
            }

            // clear current playlist
            _playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).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_TVSERIES).Add(playListItem);
            }

            // if we got a playlist
            if (_playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Count > 0)
            {
                playlist = _playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES);

                // autoshuffle on load
                if (_playlistPlayer.PlaylistAutoShuffle)
                {
                    playlist.Shuffle();
                }

                // then get 1st item
                PlayListItem item = playlist[0];

                // and activate the playlist window
                ShowPlaylistWindow();

                // and start playing it
                if (_playlistPlayer.PlaylistAutoPlay)
                {
                    _playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_TVSERIES;
                    _playlistPlayer.Reset();
                    _playlistPlayer.Play(0);
                }
            }
        }
Exemplo n.º 4
0
        protected void AddItemToPlayList()
        {
            if (_playlistPlayer == null)
            {
                _playlistPlayer = PlayListPlayer.SingletonPlayer;
                _playlistPlayer.PlaylistAutoPlay = DBOption.GetOptions(DBOption.cPlaylistAutoPlay);
                _playlistPlayer.RepeatPlaylist = DBOption.GetOptions(DBOption.cRepeatPlaylist);
            }

            SQLCondition condition = new SQLCondition();
            List<DBEpisode> episodes;

            if (this.listLevel == Listlevel.Group)
            {
                return;
            }
            else if (this.listLevel == Listlevel.Series && m_SelectedSeries != null)
            {
                condition.Add(new DBEpisode(), DBEpisode.cSeriesID, m_SelectedSeries[DBSeries.cID], SQLConditionType.Equal);
                if (DBOption.GetOptions(DBOption.cPlaylistUnwatchedOnly))
                    condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cWatched, false, SQLConditionType.Equal);
            }
            else if (this.listLevel == Listlevel.Season && m_SelectedSeason != null)
            {
                condition.Add(new DBEpisode(), DBEpisode.cSeriesID, m_SelectedSeries[DBSeries.cID], SQLConditionType.Equal);
                condition.Add(new DBEpisode(), DBEpisode.cSeasonIndex, m_SelectedSeason[DBSeason.cIndex], SQLConditionType.Equal);
                if (DBOption.GetOptions(DBOption.cPlaylistUnwatchedOnly))
                    condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cWatched, false, SQLConditionType.Equal);
            }
            else if (this.listLevel == Listlevel.Episode && m_SelectedEpisode != null)
            {
                condition.Add(new DBEpisode(), DBEpisode.cSeriesID, m_SelectedSeries[DBSeries.cID], SQLConditionType.Equal);
                condition.Add(new DBEpisode(), DBEpisode.cSeasonIndex, m_SelectedSeason[DBSeason.cIndex], SQLConditionType.Equal);
                condition.Add(new DBEpisode(), DBEpisode.cEpisodeIndex, m_SelectedEpisode[DBEpisode.cEpisodeIndex], SQLConditionType.Equal);
            }

            episodes = DBEpisode.Get(condition, false);
            episodes.Sort();

            foreach (DBEpisode episode in episodes)
            {
                PlayListItem playlistItem = new PlayListItem(episode);
                _playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Add(playlistItem);
            }

            // Select next item in list
            int item = m_Facade.SelectedListItemIndex;
            if (item < m_Facade.Count)
                m_Facade.SelectedListItemIndex = item + 1;
        }