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); } } }
/// <summary> /// Private method to start playlist (needed for the invoke callback) /// </summary> private static void StartPlayingPlaylist(bool switchToPlaylistView) { if (GUIGraphicsContext.form.InvokeRequired) { StartPlayingPlaylistDelegate d = StartPlayingPlaylist; GUIGraphicsContext.form.Invoke(d, new object[] { switchToPlaylistView }); } else { PlayListPlayer playlistPlayer = PlayListPlayer.SingletonPlayer; PlayList playlist = playlistPlayer.GetPlaylist(mPlaylistStartType); // if we got a playlist if (playlist.Count > 0) { // and activate the playlist window if its not activated yet if (switchToPlaylistView) { if (mPlaylistStartType == PlayListType.PLAYLIST_MUSIC) { WindowPluginHelper.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_MUSIC_PLAYLIST); } else if (mPlaylistStartType == PlayListType.PLAYLIST_VIDEO) { WindowPluginHelper.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_VIDEO_PLAYLIST); } } // and start playing it playlistPlayer.CurrentPlaylistType = mPlaylistStartType; playlistPlayer.Reset(); playlistPlayer.Play(mPlaylistStartIndex); } } }
private void LoadAndStartPlayList() { PlaylistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC; if (g_Player.CurrentFile == "") { PlayList playList = PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC); if (playList != null && playList.Count > 0) { this.CurrentTrackFileName = playList[0].FileName; PlaylistPlayer.Play(0); OnPlayBackStarted(g_Player.MediaType.Music, g_Player.CurrentFile); } } }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { var user = LastFMLibrary.CurrentUser; if (string.IsNullOrEmpty(user)) { Log.Error("No last.fm User Setup. Unable to play last.fm radio"); var dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_NOTIFY); if (null != dlgNotify) { dlgNotify.SetHeading(GUILocalizeStrings.Get(107890)); dlgNotify.SetText(GUILocalizeStrings.Get(34064)); dlgNotify.DoModal(GetID); } return; } if (controlId == (int)SkinControls.USER_RECOMMENDED_BUTTON) { TuneToStation("lastfm://user/" + user + "/recommended"); } if (controlId == (int)SkinControls.USER_MIX_BUTTON) { TuneToStation("lastfm://user/" + user + "/mix"); } if (controlId == (int)SkinControls.USER_LIBRARY_BUTTON) { TuneToStation("lastfm://user/" + user + "/library"); } if (controlId == (int)SkinControls.ARTIST_BUTTON) { string strArtist = GetInputFromUser(_lastArtist); if (!string.IsNullOrEmpty(strArtist)) { _lastArtist = strArtist; TuneToStation("lastfm://artist/" + strArtist + "/similarartists"); } } if (controlId == (int)SkinControls.TAG_BUTTON) { string strTag = GetInputFromUser(_lastTag); if (!string.IsNullOrEmpty(strTag)) { _lastTag = strTag; TuneToStation("lastfm://globaltags/" + strTag); } } if (controlId == (int)SkinControls.PLAYLIST_CONTROL) { if (PlaylistControl.SelectedListItem.Path != null && g_Player.currentFileName != null) { if (PlaylistControl.SelectedListItem.Path == g_Player.currentFileName) { //Not sure why this is called for current track but somehow OnClicked is getting fired //for current track with no user interaction. Ignore these events return; } } _playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_LAST_FM; _playlistPlayer.Play(PlaylistControl.SelectedListItemIndex); } base.OnClicked(controlId, control, actionType); }
/// <summary> /// Play all episodes of a season /// </summary> /// <param name="seriesId">ID of a series</param> /// <param name="seasonNumber">Number of the season</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 PlaySeason(int seriesId, int seasonNumber, bool autostart, int startIndex, bool onlyUnwatched, bool switchToPlaylistView) { if (GUIGraphicsContext.form.InvokeRequired) { PlaySeasonAsyncDelegate d = new PlaySeasonAsyncDelegate(PlaySeason); GUIGraphicsContext.form.Invoke(d, new object[] { seriesId, seasonNumber, autostart, startIndex, onlyUnwatched, switchToPlaylistView }); return; } List <DBEpisode> episodes = DBEpisode.Get(seriesId, seasonNumber); 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); } }
/// <summary> /// Loads a playlist and starts the playback /// </summary> /// <param name="playListFileName">Filename of the playlist</param> private void LoadPlayList(string playListFileName) { IPlayListIO loader = PlayListFactory.CreateIO(playListFileName); PlayList playlist = new PlayList(); if (!loader.Load(playlist, playListFileName)) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(6); dlgOk.SetLine(1, 477); dlgOk.SetLine(2, String.Empty); dlgOk.DoModal(GetID); } return; } if (playlist.Count == 1) { string movieFileName = playlist[0].FileName + ".mplayer"; if (movieFileName.StartsWith("rtsp:")) { movieFileName = "ZZZZ:" + movieFileName.Remove(0, 5); } if (g_Player.Play(movieFileName)) { if (g_Player.Player != null && g_Player.IsVideo) { GUIGraphicsContext.IsFullScreenVideo = true; GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO); } } return; } PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Clear(); for (int i = 0; i < playlist.Count; ++i) { string movieFileName = playlist[i].FileName + ".mplayer"; if (movieFileName.StartsWith("rtsp:")) { movieFileName = "ZZZZ:" + movieFileName.Remove(0, 5); } playlist[i].FileName = movieFileName; PlayListItem playListItem = playlist[i]; playListItem.Type = PlayListItem.PlayListItemType.Unknown; PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Add(playListItem); } if (PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO).Count > 0) { PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO); PlaylistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO; PlaylistPlayer.Reset(); PlaylistPlayer.Play(0); if (g_Player.Player != null && g_Player.IsVideo) { GUIGraphicsContext.IsFullScreenVideo = true; GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO); } } }