/// <summary> /// Gets the playlist for a given type /// </summary> /// <param name="type">Type of the playlist</param> /// <returns>List of all playlist items</returns> public static List <PlaylistEntry> GetPlaylistItems(String type) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(plType); List <PlaylistEntry> retList = new List <PlaylistEntry>(); foreach (PlayListItem item in playList) { PlaylistEntry entry = new PlaylistEntry(); entry.FileName = item.FileName; entry.Name = item.Description; entry.Duration = item.Duration; entry.Played = item.Played; if (item.Type == PlayListItem.PlayListItemType.Audio) { MpMusicHelper.AddMpExtendedInfo(item, entry); } retList.Add(entry); } return(retList); }
/// <summary> /// Retrieves the repeat mode of the playlist /// </summary> /// <param name="type">Type of the playlist</param> public static bool GetPlaylistRepeat(String type) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; return(playListPlayer.RepeatPlaylist); }
private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if (args.ChosenSuggestion != null) { _selectedType = (PlayListType)args.ChosenSuggestion; } }
/// <summary> /// Starts playing the playlist from a given index /// </summary> /// <param name="type">Type of the playlist</param> /// <param name="index">Index where playback is started</param> /// <param name="switchToPlaylistView"><code>true</code> to switch to playlist view</param> public static void StartPlayingPlaylist(String type, int index, bool switchToPlaylistView) { mPlaylistStartIndex = index; mPlaylistStartType = GetTypeFromString(type); StartPlayingPlaylist(switchToPlaylistView); }
public PlayList GetPlaylist(PlayListType nPlayList) { switch (nPlayList) { case PlayListType.PLAYLIST_MUSIC: return(_musicPlayList); case PlayListType.PLAYLIST_MUSIC_TEMP: return(_tempMusicPlayList); case PlayListType.PLAYLIST_VIDEO: return(_videoPlayList); case PlayListType.PLAYLIST_VIDEO_TEMP: return(_tempVideoPlayList); case PlayListType.PLAYLIST_MUSIC_VIDEO: return(_musicVideoPlayList); case PlayListType.PLAYLIST_RADIO_STREAMS: return(_radioStreamPlayList); default: _emptyPlayList.Clear(); return(_emptyPlayList); } }
/// <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); } } } }
public void PlayNext() { if (_currentPlayList == PlayListType.PLAYLIST_NONE) { return; } PlayList playlist = GetPlaylist(_currentPlayList); if (playlist.Count <= 0) { return; } int iItem = _currentItem; iItem++; if (iItem >= playlist.Count) { if (!_repeatPlayList) { _currentPlayList = PlayListType.PLAYLIST_NONE; return; } iItem = 0; } if (!Play(iItem)) { if (!g_Player.Playing) { PlayNext(); } } }
public PlayList(PlayListType type) { Instance.CallAssign( new PythonFunction(PyModule.Xbmc, "PlayList"), new List <object> { type.GetString() } ); }
/// <summary> /// Retrieves the name of the playlist /// </summary> /// <param name="type">Type of the playlist</param> public static String GetPlaylistName(String type) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(plType); WifiRemote.LogMessage("Playlist name test:" + playList.Name, WifiRemote.LogType.Debug); return(playList.Name); }
public PlayList(PlayListType type) { Instance.CallAssign( _ctor, new List <object> { type.GetString() }, EscapeFlags.None ); }
private void playlistPlayer_Changed(PlayListType nPlayList, PlayList playlist) { // update of playlist control is done by skin engine when moving item up / down // but moving the item in the playlist triggers an event // we do not want to reload if an item has been moved if (!_movingItem) { DoRefreshList(); } }
public PlayList GetPlaylist(PlayListType nPlayList) { switch (nPlayList) { case PlayListType.PLAYLIST_TVSERIES: return(_tvseriesPlayList); default: _emptyPlayList.Clear(); return(_emptyPlayList); } }
/// <summary> /// Clears the playlist (removes all entries) /// </summary> /// <param name="type">Type of the playlist</param> public static void ClearPlaylist(String type, bool refresh) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(plType); playList.Clear(); if (refresh) { RefreshPlaylistIfVisible(); } }
public void PlayNext(bool setFullScreenVideo) { if (_currentPlayList == PlayListType.PLAYLIST_NONE) { return; } PlayList playlist = GetPlaylist(_currentPlayList); if (playlist.Count <= 0) { return; } int iSong = _currentItem; iSong++; if (iSong >= playlist.Count) { // Is last element of video stacking playlist? if (_currentPlayList == PlayListType.PLAYLIST_VIDEO_TEMP) { // Disable playlist playback _currentPlayList = PlayListType.PLAYLIST_NONE; return; } if (!_repeatPlayList) { // Switch back to standard playback mode if (Player.BassMusicPlayer.IsDefaultMusicPlayer) { Player.BassMusicPlayer.Player.SwitchToDefaultPlaybackMode(); return; } _currentPlayList = PlayListType.PLAYLIST_NONE; return; } iSong = 0; } if (!Play(iSong, setFullScreenVideo)) { if (!g_Player.Playing) { PlayNext(); } } }
public void Remove(PlayListType type, string filename) { PlayList playlist = GetPlaylist(type); int itemRemoved = playlist.Remove(filename); if (type != CurrentPlaylistType) { return; } if (_currentItem >= itemRemoved) { _currentItem--; } }
/// <summary> /// Set repeat if type is of the current playlist type /// </summary> /// <param name="type">Type of the playlist</param> public static void Repeat(string type, bool repeat) { WifiRemote.LogMessage("Set playlist repeat:" + repeat, WifiRemote.LogType.Debug); PlayListType plType = GetTypeFromString(type); WifiRemote.LogMessage("plType:" + plType, WifiRemote.LogType.Debug); WifiRemote.LogMessage("currentType:" + PlayListPlayer.SingletonPlayer.CurrentPlaylistType, WifiRemote.LogType.Debug); if (plType == PlayListPlayer.SingletonPlayer.CurrentPlaylistType) { PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; playListPlayer.RepeatPlaylist = repeat; RefreshPlaylistIfVisible(); } }
/// <summary> /// Removes a song (identified by index in the playlist) from the playlist /// </summary> /// <param name="type">Type of the playlist</param> /// <param name="index">Index that should be removed</param> public static void RemoveItemFromPlaylist(String type, int index) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(plType); if (playList.Count > index) { PlayListItem item = playList[index]; playList.Remove(item.FileName); } RefreshPlaylistIfVisible(); }
public void ReplacePlaylist(PlayListType nPlayList, PlayList playlist) { if (playlist == null) { playlist = new PlayList(); } playlist.OnChanged -= NotifyChange; playlist.OnChanged += new PlayList.OnChangedDelegate(NotifyChange); switch (nPlayList) { case PlayListType.PLAYLIST_MUSIC: _musicPlayList = playlist; break; case PlayListType.PLAYLIST_MUSIC_TEMP: _tempMusicPlayList = playlist; break; case PlayListType.PLAYLIST_VIDEO: _videoPlayList = playlist; break; case PlayListType.PLAYLIST_VIDEO_TEMP: _tempVideoPlayList = playlist; break; case PlayListType.PLAYLIST_MUSIC_VIDEO: _musicVideoPlayList = playlist; break; case PlayListType.PLAYLIST_RADIO_STREAMS: _radioStreamPlayList = playlist; break; case PlayListType.PLAYLIST_LAST_FM: _lastFMPlaylist = playlist; break; default: _emptyPlayList = playlist; break; } NotifyChange(playlist); }
/// <summary> /// Load a playlist from disc. /// </summary> /// <param name="type">Type of the playlist</param> /// <param name="name">Name of the playlist (file)</param> /// <param name="shuffle"><code>true</code> to shuffle the playlist</param> public static void LoadPlaylist(string type, string name, bool shuffle) { // Only working for music atm PlayListType plType = GetTypeFromString(type); if (plType == PlayListType.PLAYLIST_MUSIC) { string playlistPath = String.Empty; // Playlist path supplied if (name.EndsWith(".m3u")) { playlistPath = name; } // Playlist name supplied else { // Get playlist folder from mp config using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { string playlistFolder = reader.GetValueAsString("music", "playlists", ""); if (!Path.IsPathRooted(playlistFolder)) { playlistFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), playlistFolder); } playlistPath = Path.Combine(playlistFolder, name + ".m3u"); } } if (File.Exists(playlistPath)) { // Load playlist from file PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC); PlayListM3uIO m3uPlayList = new PlayListM3uIO(); m3uPlayList.Load(playList, playlistPath); // Shuffle playlist if (shuffle) { Shuffle(type); } } } }
private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { var matchingContacts = DataProvider.Instance.GetPlayListTypesAsync((i) => i.Name.IndexOf(sender.Text, StringComparison.CurrentCultureIgnoreCase) > -1); sender.ItemsSource = matchingContacts; if (matchingContacts.Count == 0) { _selectedType = new PlayListType() { Name = sender.Text } } ; } } }
/// <summary> /// Adds a song to a playlist /// </summary> /// <param name="type">Type of the playlist</param> /// <param name="entry">Item that gets added</param> /// <param name="index">Index where the item should be added</param> /// <param name="refresh">Should the playlist be refreshed after the item is added</param> public static void AddItemToPlaylist(String type, PlaylistEntry entry, int index, bool refresh) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(plType); PlayListItem item = null; //If it's a music item, try to find it in the db if (plType == PlayListType.PLAYLIST_MUSIC) { MusicDatabase mpMusicDb = MusicDatabase.Instance; Song song = new Song(); bool inDb = mpMusicDb.GetSongByFileName(entry.FileName, ref song); if (inDb) { item = ToPlayListItem(song); } } else if (plType == PlayListType.PLAYLIST_VIDEO) { IMDBMovie movie = new IMDBMovie(); int id = VideoDatabase.GetMovieInfo(entry.FileName, ref movie); if (id > 0) { item = ToPlayListItem(movie); } } if (item == null) { item = new PlayListItem(entry.Name, entry.FileName, entry.Duration); } playList.Insert(item, index); if (refresh) { RefreshPlaylistIfVisible(); } }
public void PlayNext() { if (_currentPlayList == PlayListType.PLAYLIST_NONE) { return; } PlayList playlist = GetPlaylist(_currentPlayList); if (playlist.Count <= 0) { return; } int iSong = _currentItem; iSong++; if (iSong >= playlist.Count) { // Is last element of video stacking playlist? if (_currentPlayList == PlayListType.PLAYLIST_VIDEO_TEMP) { // Disable playlist playback _currentPlayList = PlayListType.PLAYLIST_NONE; return; } if (!_repeatPlayList) { _currentPlayList = PlayListType.PLAYLIST_NONE; return; } iSong = 0; } if (!Play(iSong)) { if (!g_Player.Playing) { PlayNext(); } } }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (_selectedType == null || string.IsNullOrEmpty(PlaylistName.Text)) { return; } if (_selectedType.ID <= 0) { _selectedType = await DataProvider.Instance.AddPlayListTypeAsync(_selectedType); } var preResult = new PlayList() { Name = PlaylistName.Text, TypeID = _selectedType.ID, Type = _selectedType }; Result = await DataProvider.Instance.AddPlayListAsync(preResult); Hide(); }
/// <summary> /// Handle an MpExtended message received from a client /// </summary> /// <param name="message">Message</param> /// <param name="socketServer">Socket server</param> /// <param name="sender">Sender</param> internal static void HandleMpExtendedMessage(Newtonsoft.Json.Linq.JObject message, SocketServer socketServer, Deusty.Net.AsyncSocket sender) { string itemId = (string)message["ItemId"]; int itemType = (int)message["MediaType"]; int providerId = (int)message["ProviderId"]; String action = (String)message["Action"]; Dictionary <string, string> values = JsonConvert.DeserializeObject <Dictionary <string, string> >(message["PlayInfo"].ToString()); int startPos = (message["StartPosition"] != null) ? (int)message["StartPosition"] : 0; if (action != null) { if (action.Equals("play")) { //play the item in MediaPortal WifiRemote.LogMessage("play mediaitem: ItemId: " + itemId + ", itemType: " + itemType + ", providerId: " + providerId, WifiRemote.LogType.Debug); MpExtendedHelper.PlayMediaItem(itemId, itemType, providerId, values, startPos); } else if (action.Equals("show")) { //show the item details in mediaportal (without starting playback) WifiRemote.LogMessage("show mediaitem: ItemId: " + itemId + ", itemType: " + itemType + ", providerId: " + providerId, WifiRemote.LogType.Debug); MpExtendedHelper.ShowMediaItem(itemId, itemType, providerId, values); } else if (action.Equals("enqueue")) { //enqueue the mpextended item to the currently active playlist WifiRemote.LogMessage("enqueue mediaitem: ItemId: " + itemId + ", itemType: " + itemType + ", providerId: " + providerId, WifiRemote.LogType.Debug); int startIndex = (message["StartIndex"] != null) ? (int)message["StartIndex"] : -1; PlayListType playlistType = PlayListType.PLAYLIST_VIDEO; List <PlayListItem> items = MpExtendedHelper.CreatePlayListItemItem(itemId, itemType, providerId, values, out playlistType); PlaylistHelper.AddPlaylistItems(playlistType, items, startIndex); } } else { WifiRemote.LogMessage("No MpExtended action defined", WifiRemote.LogType.Warn); } }
private void NotifyChange(PlayList playlist) { PlayListType nPlaylist = PlayListType.PLAYLIST_NONE; if (_musicPlayList == playlist) { nPlaylist = PlayListType.PLAYLIST_MUSIC; } else if (_tempMusicPlayList == playlist) { nPlaylist = PlayListType.PLAYLIST_MUSIC_TEMP; } else if (_videoPlayList == playlist) { nPlaylist = PlayListType.PLAYLIST_VIDEO; } else if (_tempVideoPlayList == playlist) { nPlaylist = PlayListType.PLAYLIST_VIDEO_TEMP; } else if (_musicVideoPlayList == playlist) { nPlaylist = PlayListType.PLAYLIST_MUSIC_VIDEO; } else if (_radioStreamPlayList == playlist) { nPlaylist = PlayListType.PLAYLIST_RADIO_STREAMS; } else if (_lastFMPlaylist == playlist) { nPlaylist = PlayListType.PLAYLIST_LAST_FM; } else { nPlaylist = PlayListType.PLAYLIST_NONE; } if (nPlaylist != PlayListType.PLAYLIST_NONE && PlaylistChanged != null) { PlaylistChanged(nPlaylist, playlist); } }
/// <summary> /// Add a list of playlist items to the current playlist /// </summary> /// <param name="type">Type of playlist (e.g. video/music)</param> /// <param name="items">Items that we want to add</param> /// <param name="startIndex">Where should the items be added (-1 will append them at the end)</param> internal static void AddPlaylistItems(PlayListType type, List <PlayListItem> items, int startIndex) { PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(type); if (startIndex == -1 || startIndex >= playList.Count) { startIndex = playList.Count; } else if (startIndex < 0) { startIndex = 0; } for (int i = 0; i < items.Count; i++) { //Note: we need -1 here, because Insert wants the item after which the song should be inserted, not the actual index playList.Insert(items[i], i + startIndex - 1); } }
private void OnPlaylistChanged(PlayListType nPlayList, PlayList playlist) { // changes to the current track are dealt with by g_player events // but user can udpate the playlist without firing g_player events // make sure the next track details shown are correct if ((_playlistIsCurrent && nPlayList == PlayListType.PLAYLIST_MUSIC) || (!_playlistIsCurrent && nPlayList == PlayListType.PLAYLIST_MUSIC_TEMP)) { var nextFilename = playlistPlayer.GetNext(); if (!string.IsNullOrEmpty(nextFilename)) { var tag = GetTag(nextFilename); SetNextSkinProperties(tag, nextFilename); } else { SetNextSkinProperties(null, string.Empty); } } }
/// <summary> /// Changes the position of an item in the playlist /// </summary> /// <param name="type">Type of the playlist</param> /// <param name="oldIndex">Current position of item</param> /// <param name="newIndex">Target position of item</param> public static void ChangePlaylistItemPosition(String type, int oldIndex, int newIndex) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(plType); if (oldIndex >= 0 && newIndex >= 0 && playList.Count > oldIndex && playList.Count > newIndex) { WifiRemote.LogMessage("Change playlist index " + oldIndex + " to " + newIndex, WifiRemote.LogType.Debug); PlayListItem item = playList[oldIndex]; playList.Remove(item.FileName); //Note: we need -1 here, because Insert wants the item after which the song should be inserted, not the actual index playList.Insert(item, newIndex - 1); RefreshPlaylistIfVisible(); } else { WifiRemote.LogMessage("Index for changing playlistPosition invalid (old: " + oldIndex + ", new: " + newIndex + ")", WifiRemote.LogType.Warn); } }
public virtual void Save(System.String FileName, PlayListType FileType) { System.IO.FileStream File = System.IO.File.Create(this.MusicPath + System.IO.Path.DirectorySeparatorChar + FileName); System.Text.ASCIIEncoding Encoder = new System.Text.ASCIIEncoding(); System.String Content; switch (FileType) { case PlayListType.pls: Content = this.GetPLS(); break; case PlayListType.m3u: Content = this.GetM3U(); break; default: Content = this.GetSMIL(); break; } File.Write(Encoder.GetBytes(Content), 0, Encoder.GetByteCount(Content)); File.Flush(); File.Close(); }
/// <summary> /// Play a media item described by its' MpExtended properties (item id/item type/provider id) /// </summary> /// <param name="itemId">MpExtended item id</param> /// <param name="mediaType">MpExtended media type</param> /// <param name="providerId">MpExtended provider id</param> /// <param name="playInfo">Additional information to playback the item</param> public static List<PlayListItem> CreatePlayListItemItem(string itemId, int mediaType, int providerId, Dictionary<string, string> playInfo, out PlayListType playlistType) { playlistType = PlayListType.PLAYLIST_VIDEO;//default to video try { List<PlayListItem> items = new List<PlayListItem>(); MpExtendedProviders provider = (MpExtendedProviders)providerId; MpExtendedMediaTypes type = (MpExtendedMediaTypes)mediaType; switch (provider) { case MpExtendedProviders.MovingPictures: if (WifiRemote.IsAvailableMovingPictures) { playlistType = PlayListType.PLAYLIST_VIDEO; items.Add(MovingPicturesHelper.CreatePlaylistItem(Int32.Parse(playInfo["Id"]))); } else { WifiRemote.LogMessage("MovingPictures not installed but required!", WifiRemote.LogType.Error); } break; case MpExtendedProviders.MPTvSeries: if (WifiRemote.IsAvailableTVSeries) { playlistType = PlayListType.PLAYLIST_VIDEO; if (type == MpExtendedMediaTypes.TVEpisode) { items.Add(TVSeriesHelper.CreatePlaylistItemFromEpisode(playInfo["Id"])); } else if (type == MpExtendedMediaTypes.TVSeason) { items = TVSeriesHelper.CreatePlaylistItemsFromSeason(Int32.Parse(playInfo["ShowId"]), Int32.Parse(playInfo["SeasonIndex"])); } else if (type == MpExtendedMediaTypes.TVShow) { items = TVSeriesHelper.CreatePlaylistItemsFromShow(Int32.Parse(playInfo["Id"])); } } else { WifiRemote.LogMessage("MP-TvSeries not installed but required!", WifiRemote.LogType.Error); } break; case MpExtendedProviders.MPMusic: playlistType = PlayListType.PLAYLIST_MUSIC; if (type == MpExtendedMediaTypes.MusicTrack) { items.Add(MpMusicHelper.CreatePlaylistItemFromMusicTrack(Int32.Parse(playInfo["Id"]))); } else if (type == MpExtendedMediaTypes.MusicAlbum) { items = MpMusicHelper.CreatePlaylistItemsFromMusicAlbum(playInfo["Artist"], playInfo["Album"]); } else if (type == MpExtendedMediaTypes.MusicArtist) { items = MpMusicHelper.CreatePlaylistItemsFromMusicArtist(playInfo["Artist"]); // MpMusicHelper.PlayArtist(playInfo["Artist"], startPos); } break; case MpExtendedProviders.MPVideo: playlistType = PlayListType.PLAYLIST_VIDEO; //MpVideosHelper.PlayVideo(Int32.Parse(playInfo["Id"]), startPos); break; case MpExtendedProviders.MpVideosShare: playlistType = PlayListType.PLAYLIST_VIDEO; if (type == MpExtendedMediaTypes.File) { //TODO: fill myvideos db information instead of just playing the file items.Add(MpVideosHelper.CreatePlaylistItemFromVideoFile(playInfo["Path"])); } else if (type == MpExtendedMediaTypes.Folder) { string[] extensions = playInfo["Extensions"].Split('|'); items = MpVideosHelper.CreatePlaylistItemFromVideoFolder(playInfo["Path"], extensions); } break; case MpExtendedProviders.MpMusicShare: playlistType = PlayListType.PLAYLIST_MUSIC; if (type == MpExtendedMediaTypes.File) { //MpMusicHelper.PlayFile(playInfo["Path"], startPos); } else if (type == MpExtendedMediaTypes.Folder) { //string[] extensions = playInfo["Extensions"].Split('|'); //MpMusicHelper.PlayAllFilesInFolder(playInfo["Path"], extensions, startPos); } break; default: playlistType = PlayListType.PLAYLIST_VIDEO; //we have no providers (yet) for tv if (type == MpExtendedMediaTypes.Recording) { if (!WifiRemote.IsAvailableTVPlugin) { WifiRemote.LogMessage("No TVPlugin installed: Aborting playrecording", WifiRemote.LogType.Error); return null; } items.Add(MpTvServerHelper.CreatePlaylistItemFromRecording(Int32.Parse(playInfo["Id"]))); } else { WifiRemote.LogMessage("Provider not implemented yet", WifiRemote.LogType.Warn); } break; } return items; } catch (Exception ex) { WifiRemote.LogMessage("Error during play of MediaItem: " + ex.ToString(), WifiRemote.LogType.Error); } return null; }
public static void PlayMovie(int idMovie, bool requestPin) { int selectedFileIndex = 1; if (IsStacked) { selectedFileIndex = 0; } ArrayList movieFiles = new ArrayList(); VideoDatabase.GetFilesForMovie(idMovie, ref movieFiles); if (movieFiles.Count <= 0 || !CheckMovie(idMovie)) { return; } bool askForResumeMovie = true; int movieDuration = 0; List<GUIListItem> items = new List<GUIListItem>(); foreach (string file in movieFiles) { FileInformation fi = new FileInformation(); GUIListItem item = new GUIListItem(Util.Utils.GetFilename(file), "", file, false, fi); items.Add(item); if (!WakeUpSrv(item.Path)) { return; } } if (items.Count <= 0) { return; } if (requestPin) { string strDir = Path.GetDirectoryName(items[0].Path); if (strDir != null && strDir.EndsWith(@"\")) { strDir = strDir.Substring(0, strDir.Length - 1); } if (strDir == null || strDir.Length > 254) { Log.Warn("GUIVideoFiles.PlayTitleMovie: Received a path which contains too many chars"); return; } string iPincodeCorrect; if (_virtualDirectory.IsProtectedShare(strDir, out iPincodeCorrect)) { #region Pin protected bool retry = true; { while (retry) { //no, then ask user to enter the pincode GUIMessage msgGetPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0); GUIWindowManager.SendMessage(msgGetPassword); if (msgGetPassword.Label != iPincodeCorrect) { GUIMessage msgWrongPassword = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WRONG_PASSWORD, 0, 0, 0, 0, 0, 0); GUIWindowManager.SendMessage(msgWrongPassword); if (!(bool)msgWrongPassword.Object) { return; } } else { retry = false; } } } #endregion } } //check if we can resume 1 of those movies if (items.Count > 1) { bool asked = false; for (int i = 0; i < items.Count; ++i) { GUIListItem temporaryListItem = (GUIListItem)items[i]; if (!asked) { selectedFileIndex++; } IMDBMovie movieDetails = new IMDBMovie(); int idFile = VideoDatabase.GetFileId(temporaryListItem.Path); if ((idMovie >= 0) && (idFile >= 0)) { VideoDatabase.GetMovieInfo((string)movieFiles[0], ref movieDetails); string title = Path.GetFileName((string)movieFiles[0]); if ((VirtualDirectory.IsValidExtension((string)movieFiles[0], Util.Utils.VideoExtensions, false))) { Util.Utils.RemoveStackEndings(ref title); } if (movieDetails.Title != string.Empty) { title = movieDetails.Title; } int timeMovieStopped = VideoDatabase.GetMovieStopTime(idFile); if (timeMovieStopped > 0) { if (!asked) { asked = true; GUIResumeDialog.Result result = GUIResumeDialog.ShowResumeDialog(title, movieDuration + timeMovieStopped, GUIResumeDialog.MediaType.Video); if (result == GUIResumeDialog.Result.Abort) { _playlistPlayer.Reset(); _playlistPlayer.CurrentPlaylistType = _currentPlaylistType; _playlistPlayer.CurrentSong = _currentPlaylistIndex; return; } if (result == GUIResumeDialog.Result.PlayFromBeginning) { VideoDatabase.DeleteMovieStopTime(idFile); } else { askForResumeMovie = false; } } } // Total movie duration movieDuration += VideoDatabase.GetVideoDuration(idFile); } } if (askForResumeMovie) { GUIDialogFileStacking dlg = (GUIDialogFileStacking)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_FILESTACKING); if (null != dlg) { dlg.SetFiles(movieFiles); dlg.DoModal(GUIWindowManager.ActiveWindow); selectedFileIndex = dlg.SelectedFile; if (selectedFileIndex < 1) { return; } } } } // Get current playlist _currentPlaylistType = new PlayListType(); _currentPlaylistType = _playlistPlayer.CurrentPlaylistType; _currentPlaylistIndex = _playlistPlayer.CurrentSong; _playlistPlayer.Reset(); _playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO_TEMP; PlayList playlist = _playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO_TEMP); playlist.Clear(); for (int i = selectedFileIndex - 1; i < movieFiles.Count; ++i) { string movieFileName = (string)movieFiles[i]; PlayListItem newitem = new PlayListItem(); newitem.FileName = movieFileName; newitem.Type = PlayListItem.PlayListItemType.Video; playlist.Add(newitem); } // play movie... PlayMovieFromPlayList(askForResumeMovie, requestPin); }
public void OnMessage(GUIMessage message) { if(PlayListPlayer.SingletonPlayer.CurrentPlaylistType!=PlayListType.PLAYLIST_NONE) return; switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED: { PlayListItem item = GetCurrentItem(); if (item != null) { if (item.Type != PlayListItem.PlayListItemType.Radio || item.Type != PlayListItem.PlayListItemType.AudioStream) { Reset(); _currentPlayList = PlayListType.PLAYLIST_NONE; } } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } break; // SV Allows BassMusicPlayer to continuously play case GUIMessage.MessageType.GUI_MSG_PLAYBACK_CROSSFADING: { // This message is only sent by BASS in gapless/crossfading mode PlayNext(); } break; case GUIMessage.MessageType.GUI_MSG_PLAYBACK_ENDED: { // This message is sent by both the internal and BASS player // In case of gapless/crossfading it is only sent after the last song PlayNext(); if (!g_Player.Playing) { g_Player.Release(); // Clear focus when playback ended GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } } break; case GUIMessage.MessageType.GUI_MSG_PLAY_FILE: { Log.Info("YoutubePlaylistplayer: Start file ({0})", message.Label); g_Player.Play(message.Label); if (!g_Player.Playing) { g_Player.Stop(); } } break; case GUIMessage.MessageType.GUI_MSG_STOP_FILE: { Log.Info("YoutubePlaylistplayer: Stop file"); g_Player.Stop(); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_PERCENTAGE: { Log.Info("YoutubePlaylistplayer: SeekPercent ({0}%)", message.Param1); g_Player.SeekAsolutePercentage(message.Param1); Log.Debug("YoutubePlaylistplayer: SeekPercent ({0}%) done", message.Param1); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_END: { double duration = g_Player.Duration; double position = g_Player.CurrentPosition; if (position < duration - 1d) { Log.Info("YoutubePlaylistplayer: SeekEnd ({0})", duration); g_Player.SeekAbsolute(duration - 2d); Log.Debug("YoutubePlaylistplayer: SeekEnd ({0}) done", g_Player.CurrentPosition); } } break; case GUIMessage.MessageType.GUI_MSG_SEEK_POSITION: { g_Player.SeekAbsolute(message.Param1); } break; } }
private void pauseMusic() { pausedMusic = true; isPausedMusicCDA = g_Player.IsCDA; pausedPlayListType = new PlayListType(); pausedPlayListType = playlistPlayer.CurrentPlaylistType; iSong = playlistPlayer.CurrentSong; pausedMusicLastPosition = g_Player.CurrentPosition; g_Player.IsPicturePlaylist = false; }
public PlayList GetPlaylist(PlayListType nPlayList) { switch (nPlayList) { case PlayListType.PLAYLIST_MUSIC: return _musicPlayList; case PlayListType.PLAYLIST_MUSIC_TEMP: return _tempMusicPlayList; case PlayListType.PLAYLIST_VIDEO: return _videoPlayList; case PlayListType.PLAYLIST_VIDEO_TEMP: return _tempVideoPlayList; case PlayListType.PLAYLIST_MUSIC_VIDEO: return _musicVideoPlayList; case PlayListType.PLAYLIST_RADIO_STREAMS: return _radioStreamPlayList; case PlayListType.PLAYLIST_LAST_FM: return _lastFMPlaylist; default: _emptyPlayList.Clear(); return _emptyPlayList; } }
private PlayList parsePlaylist(string contentToParse, PlayListType type) { string regex = null; switch (type) { case PlayListType.m3u: regex = @"(#|.*?#)EXTINF:.*?,(?<name>.*?)(?<playlink>http.*?mp3)"; break; case PlayListType.xspf: regex = "<location>(?<playlink>http[^>]*)</location>.*?(<annotation>|<title>)(?<name>[^>]*)(</annotation>|</title>)"; break; case PlayListType.pls: regex = "File.*?=(?<playlink>.*?mp3).*?Title.*?=(?<name>.*?)Length"; break; case PlayListType.asx: regex = "<entry>.*?<title>(?<name>.*?)</title>[^>]*<Ref href=\"(?<playlink>.*?)\"/>"; break; } PlayList _playlist = new PlayList(); MatchCollection allMatchResults = null; try { Regex regexObj = new Regex(regex, RegexOptions.Singleline | RegexOptions.IgnoreCase); allMatchResults = regexObj.Matches(contentToParse); if (allMatchResults.Count > 0) { for (int i = 0; i < allMatchResults.Count; i++) { Match m = allMatchResults[i]; string name = m.Groups["name"].ToString(); string link = m.Groups["playlink"].ToString(); if (link.Contains("&")) { link = link.Replace("&", "&"); } if (link.Contains("\r")) { link = link.Replace("\r", ""); } PlayListItem item = new PlayListItem(name, link); item.Type = PlayListItem.PlayListItemType.AudioStream; _playlist.Add(item); } } } catch (ArgumentException ex) { throw ex; } return _playlist; }
/// <summary> /// Add a list of playlist items to the current playlist /// </summary> /// <param name="type">Type of playlist (e.g. video/music)</param> /// <param name="items">Items that we want to add</param> /// <param name="startIndex">Where should the items be added (-1 will append them at the end)</param> internal static void AddPlaylistItems(PlayListType type, List<PlayListItem> items, int startIndex) { PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(type); if (startIndex == -1 || startIndex >= playList.Count) { startIndex = playList.Count; } else if (startIndex < 0) { startIndex = 0; } for (int i = 0; i < items.Count; i++) { //Note: we need -1 here, because Insert wants the item after which the song should be inserted, not the actual index playList.Insert(items[i], i + startIndex - 1); } }
protected override void OnPageLoad() { base.OnPageLoad(); if (Youtube2MP._settings.UseYouTubePlayer) { _playlistType = PlayListType.PLAYLIST_VIDEO_TEMP; } else { _playlistType = PlayListType.PLAYLIST_MUSIC_VIDEO; } currentView = View.PlayList; facadeView.View = GUIFacadeControl.ViewMode.Playlist; if (ScrobblerOn) btnScrobble.Selected = true; if (_scrobbleUsers.Count < 2) btnScrobbleUser.Visible = false; btnScrobbleUser.Label = GUILocalizeStrings.Get(33005) + _currentScrobbleUser; LoadDirectory(string.Empty); if (m_iItemSelected >= 0) { GUIControl.SelectItemControl(GetID, facadeView.GetID, m_iItemSelected); } if ((m_iLastControl == facadeView.GetID) && facadeView.Count <= 0) { m_iLastControl = btnNowPlaying.GetID; GUIControl.FocusControl(GetID, m_iLastControl); } if (facadeView.Count <= 0) { GUIControl.FocusControl(GetID, btnViewAs.GetID); } using (MediaPortal.Profile.Settings settings = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { playlistPlayer.RepeatPlaylist = settings.GetValueAsBool("musicfiles", "repeat", true); } if (btnRepeatPlaylist != null) { btnRepeatPlaylist.Selected = playlistPlayer.RepeatPlaylist; } SelectCurrentPlayingSong(); }
public void PlayNext() { if (_currentPlayList == PlayListType.PLAYLIST_NONE) return; PlayList playlist = GetPlaylist(_currentPlayList); if (playlist.Count <= 0) return; int iItem = _currentItem; iItem++; if (iItem >= playlist.Count) { if (!_repeatPlayList) { _currentPlayList = PlayListType.PLAYLIST_NONE; return; } iItem = 0; } if (!Play(iItem)) { if (!g_Player.Playing) { PlayNext(); } } }
protected override void OnClick(int iItem) { GUIListItem item = facadeLayout.SelectedListItem; TotalMovieDuration = 0; IsStacked = false; StackedMovieFiles.Clear(); if (item == null) { _playClicked = false; return; } if (!WakeUpSrv(item.Path)) { return; } string path = item.Path; if (item.IsBdDvdFolder) { // Check if folder is actually a DVD. If so don't browse this folder, but play the DVD! if (File.Exists(path + @"\VIDEO_TS\VIDEO_TS.IFO")) { path = item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"; } // Then it's a Blu-Ray. Play the Blu-Ray! else { path = item.Path + @"\BDMV\index.bdmv"; } } if ((item.IsFolder && !item.IsBdDvdFolder)) { // Play all in folder if (_playClicked) { if (!item.IsRemote && item.Label != ".." && !VirtualDirectory.IsImageFile(Path.GetExtension(item.Path))) { if (!_virtualDirectory.RequestPin(item.Path)) { _playClicked = false; return; } OnPlayAll(item.Path); _playClicked = false; } } else { _currentSelectedItem = -1; if (facadeLayout != null) { _history.Set(facadeLayout.SelectedListItemIndex.ToString(), _currentFolder); } LoadDirectory(path, true); } } else { if (!_virtualDirectory.RequestPin(path)) { _playClicked = false; return; } if (_virtualDirectory.IsRemote(path)) { if (!_virtualDirectory.IsRemoteFileDownloaded(path, item.FileInfo.Length)) { if (!_virtualDirectory.ShouldWeDownloadFile(path)) { _playClicked = false; return; } if (!_virtualDirectory.DownloadRemoteFile(path, item.FileInfo.Length)) { //show message that we are unable to download the file GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SHOW_WARNING, 0, 0, 0, 0, 0, 0); msg.Param1 = 916; msg.Param2 = 920; msg.Param3 = 0; msg.Param4 = 0; GUIWindowManager.SendMessage(msg); _playClicked = false; return; } //download subtitle files Thread subLoaderThread = new Thread(DownloadSubtitles); subLoaderThread.IsBackground = true; subLoaderThread.Name = "SubtitleLoader"; subLoaderThread.Start(); } } if (item.FileInfo != null) { if (!_virtualDirectory.IsRemoteFileDownloaded(path, item.FileInfo.Length)) { _playClicked = false; return; } } string movieFileName = path; movieFileName = _virtualDirectory.GetLocalFilename(movieFileName); if (PlayListFactory.IsPlayList(movieFileName)) { LoadPlayList(movieFileName); _playClicked = false; return; } if (!CheckMovie(movieFileName)) { _playClicked = false; return; } if (_videoInfoInShare && VideoDatabase.HasMovieInfo(movieFileName) && !_playClicked) { OnInfo(facadeLayout.SelectedListItemIndex); return; } bool askForResumeMovie = true; _playClicked = false; #region StackEnabled and file is stackable // Proceed to file stack check if file is stackable if (_mapSettings.Stack && IsFileStackable(movieFileName)) { IsStacked = true; int selectedFileIndex = 0; int movieDuration = 0; ArrayList movies = new ArrayList(); List<GUIListItem> items = new List<GUIListItem>(); IMDBMovie movie = item.AlbumInfoTag as IMDBMovie; // This will return all stackable files for current clicked item // Also will add all stackable files to videodatabase if they are not exist StackedMovieFiles = AddFileToDatabase(movieFileName); // Add movie files to list foreach (string file in StackedMovieFiles) { FileInformation fi = new FileInformation(); GUIListItem itemMovie = new GUIListItem(Util.Utils.GetFilename(file), "", file, false, fi); items.Add(itemMovie); } // In the list must be at least 2 files so we check stackable movie for resume // (which file have a stop time) bool asked = false; string title = item.Label; // Dlg title if (movie != null && !movie.IsEmpty) { title = movie.Title; } for (int i = 0; i < items.Count; ++i) { IMDBMovie.SetMovieData(items[i]); // This will set IMDBMovie object and it will never be null movie = items[i].AlbumInfoTag as IMDBMovie; if (!asked) { selectedFileIndex++; } int idFile = VideoDatabase.GetFileId(movie.VideoFileName); if (idFile != -1) { int timeMovieStopped = VideoDatabase.GetMovieStopTime(idFile); if (timeMovieStopped > 0) { if (!asked) { asked = true; GUIResumeDialog.Result result = GUIResumeDialog.ShowResumeDialog(title, movieDuration + timeMovieStopped, GUIResumeDialog.MediaType.Video); if (result == GUIResumeDialog.Result.Abort) { _playlistPlayer.Reset(); _playlistPlayer.CurrentPlaylistType = _currentPlaylistType; _playlistPlayer.CurrentSong = _currentPlaylistIndex; return; } if (result == GUIResumeDialog.Result.PlayFromBeginning) { VideoDatabase.DeleteMovieStopTime(idFile); } else { askForResumeMovie = false; } } } // Total movie duration movieDuration += VideoDatabase.GetVideoDuration(idFile); TotalMovieDuration = movieDuration; } } for (int i = 0; i < items.Count; ++i) { GUIListItem temporaryListItem = (GUIListItem)items[i]; movie = (IMDBMovie)temporaryListItem.AlbumInfoTag; if (Util.Utils.IsVideo(movie.VideoFileName) && !PlayListFactory.IsPlayList(movie.VideoFileName)) { movies.Add(movie.VideoFileName); } } if (movies.Count == 0) { movies.Add(movieFileName); } if (movies.Count > 1) { movies.Sort(); // Stacked movies duration if (TotalMovieDuration == 0) { MovieDuration(movies, false); StackedMovieFiles = movies; } // Ask for resume if (askForResumeMovie) { GUIDialogFileStacking dlg = (GUIDialogFileStacking) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_FILESTACKING); if (null != dlg) { dlg.SetFiles(movies); dlg.DoModal(GetID); selectedFileIndex = dlg.SelectedFile; if (selectedFileIndex < 1) { return; } } } } // This can happen if user have one file and it is stackable (filename ends with CDx...) else { MovieDuration(movies, false); } // Get current playlist _currentPlaylistType = new PlayListType(); _currentPlaylistType = _playlistPlayer.CurrentPlaylistType; _currentPlaylistIndex = _playlistPlayer.CurrentSong; _playlistPlayer.Reset(); _playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO_TEMP; PlayList playlist = _playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO_TEMP); playlist.Clear(); for (int i = 0; i < (int) movies.Count; ++i) { movieFileName = (string) movies[i]; PlayListItem itemNew = new PlayListItem(); itemNew.FileName = movieFileName; itemNew.Type = PlayListItem.PlayListItemType.Video; playlist.Add(itemNew); } // play movie...(2 or more files) PlayMovieFromPlayList(askForResumeMovie, selectedFileIndex - 1, true); return; } #endregion #region StackDisabled or file not stackable // play movie...(only 1 file) AddFileToDatabase(movieFileName); // Get current playlist _currentPlaylistType = new PlayListType(); _currentPlaylistType = _playlistPlayer.CurrentPlaylistType; _currentPlaylistIndex = _playlistPlayer.CurrentSong; _playlistPlayer.Reset(); _playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO_TEMP; PlayList newPlayList = _playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO_TEMP); newPlayList.Clear(); PlayListItem NewItem = new PlayListItem(); NewItem.FileName = movieFileName; NewItem.Type = PlayListItem.PlayListItemType.Video; newPlayList.Add(NewItem); PlayMovieFromPlayList(true, true); #endregion } }
public void ReplacePlaylist(PlayListType nPlayList, PlayList playlist) { if (playlist == null) playlist = new PlayList(); playlist.OnChanged -= NotifyChange; playlist.OnChanged +=new PlayList.OnChangedDelegate(NotifyChange); switch (nPlayList) { case PlayListType.PLAYLIST_MUSIC: _musicPlayList = playlist; break; case PlayListType.PLAYLIST_MUSIC_TEMP: _tempMusicPlayList = playlist; break; case PlayListType.PLAYLIST_VIDEO: _videoPlayList = playlist; break; case PlayListType.PLAYLIST_VIDEO_TEMP: _tempVideoPlayList = playlist; break; case PlayListType.PLAYLIST_MUSIC_VIDEO: _musicVideoPlayList = playlist; break; case PlayListType.PLAYLIST_RADIO_STREAMS: _radioStreamPlayList = playlist; break; case PlayListType.PLAYLIST_LAST_FM: _lastFMPlaylist = playlist; break; default: _emptyPlayList = playlist; break; } NotifyChange(playlist); }
protected static Rectangle _backupBounds; // Bounds backup #endregion #region constructor /// <summary> /// Constructor /// </summary> protected D3D() { _firstTimeWindowDisplayed = true; _firstTimeActivated = true; MinimizeOnStartup = false; MinimizeOnGuiExit = false; MinimizeOnFocusLoss = false; ShuttingDown = false; AutoHideMouse = true; MouseCursor = true; Windowed = true; Volume = -1; AppActive = false; KeyPreview = true; Frames = 0; FrameStatsLine1 = null; FrameStatsLine2 = null; Text = Resources.D3DApp_NotifyIcon_MediaPortal; PlaylistPlayer = PlayListPlayer.SingletonPlayer; MouseTimeOutTimer = DateTime.Now; _lastActiveWindow = -1; IsVisible = true; IsDisplayTurnedOn = true; IsInAwayMode = false; IsUserPresent = true; _lastMouseCursor = !MouseCursor; _showCursorWhenFullscreen = false; _currentPlayListType = PlayListType.PLAYLIST_NONE; _enumerationSettings = new D3DEnumeration(); _presentParams = new PresentParameters(); _renderTarget = this; using (Settings xmlreader = new MPSettings()) { _useExclusiveDirectXMode = xmlreader.GetValueAsBool("general", "exclusivemode", true); UseEnhancedVideoRenderer = xmlreader.GetValueAsBool("general", "useEVRenderer", false); _disableMouseEvents = xmlreader.GetValueAsBool("remote", "CentareaJoystickMap", false); AutoHideTaskbar = xmlreader.GetValueAsBool("general", "hidetaskbar", true); _alwaysOnTop = xmlreader.GetValueAsBool("general", "alwaysontop", false); _reduceFrameRate = xmlreader.GetValueAsBool("gui", "reduceframerate", false); _doNotWaitForVSync = xmlreader.GetValueAsBool("debug", "donotwaitforvsync", false); } _useExclusiveDirectXMode = !UseEnhancedVideoRenderer && _useExclusiveDirectXMode; GUIGraphicsContext.IsVMR9Exclusive = _useExclusiveDirectXMode; GUIGraphicsContext.IsEvr = UseEnhancedVideoRenderer; InitializeComponent(); }
public void OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED: { PlayListItem item = GetCurrentItem(); if (item != null) { if (item.Type != PlayListItem.PlayListItemType.AudioStream) { Reset(); _currentPlayList = PlayListType.PLAYLIST_NONE; } } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } break; // SV Allows BassMusicPlayer to continuously play case GUIMessage.MessageType.GUI_MSG_PLAYBACK_CROSSFADING: { // This message is only sent by BASS in gapless/crossfading mode PlayNext(); } break; case GUIMessage.MessageType.GUI_MSG_PLAYBACK_ENDED: { // This message is sent by both the internal and BASS player // In case of gapless/crossfading it is only sent after the last song PlayNext(false); if (!g_Player.Playing) { g_Player.Release(); // Clear focus when playback ended GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } } break; case GUIMessage.MessageType.GUI_MSG_PLAY_FILE: { Log.Info("Playlistplayer: Start file ({0})", message.Label); g_Player.Play(message.Label); if (!g_Player.Playing) { g_Player.Stop(); } } break; case GUIMessage.MessageType.GUI_MSG_STOP_FILE: { Log.Info("Playlistplayer: Stop file"); g_Player.Stop(); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_PERCENTAGE: { Log.Info("Playlistplayer: SeekPercent ({0}%)", message.Param1); g_Player.SeekAsolutePercentage(message.Param1); Log.Debug("Playlistplayer: SeekPercent ({0}%) done", message.Param1); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_END: { double duration = g_Player.Duration; double position = g_Player.CurrentPosition; if (position < duration - 1d) { Log.Info("Playlistplayer: SeekEnd ({0})", duration); g_Player.SeekAbsolute(duration - 2d); Log.Debug("Playlistplayer: SeekEnd ({0}) done", g_Player.CurrentPosition); } } break; case GUIMessage.MessageType.GUI_MSG_SEEK_POSITION: { g_Player.SeekAbsolute(message.Param1); } break; } }
/// <summary> /// Save player state (when form was resized) /// </summary> protected void SavePlayerState() { // Is App not minimized to tray and is a player active? if (WindowState != FormWindowState.Minimized && !_wasPlayingVideo && (g_Player.Playing && (g_Player.IsTV || g_Player.IsVideo || g_Player.IsDVD))) { _wasPlayingVideo = true; _fullscreen = g_Player.FullScreen; // Some Audio/video is playing _currentPlayerPos = g_Player.CurrentPosition; _currentPlayListType = playlistPlayer.CurrentPlaylistType; _currentPlayList = new PlayList(); Log.Info("D3D: Saving fullscreen state for resume: {0}", _fullscreen); PlayList tempList = playlistPlayer.GetPlaylist(_currentPlayListType); if (tempList.Count == 0 && g_Player.IsDVD == true) { // DVD is playing PlayListItem itemDVD = new PlayListItem(); itemDVD.FileName = g_Player.CurrentFile; itemDVD.Played = true; itemDVD.Type = PlayListItem.PlayListItemType.DVD; tempList.Add(itemDVD); } if (tempList != null) { for (int i = 0; i < (int)tempList.Count; ++i) { PlayListItem itemNew = tempList[i]; _currentPlayList.Add(itemNew); } } _strCurrentFile = playlistPlayer.Get(playlistPlayer.CurrentSong); if (_strCurrentFile.Equals(string.Empty) && g_Player.IsDVD == true) { _strCurrentFile = g_Player.CurrentFile; } Log.Info( "D3D: Form resized - Stopping media - Current playlist: Type: {0} / Size: {1} / Current item: {2} / Filename: {3} / Position: {4}", _currentPlayListType, _currentPlayList.Count, playlistPlayer.CurrentSong, _strCurrentFile, _currentPlayerPos); g_Player.Stop(); _iActiveWindow = GUIWindowManager.ActiveWindow; } }
/// <summary> /// Play next video in playlist /// </summary> public void PlayNext() { timerClearProperty.Enabled = false; if (_currentPlayList == PlayListType.PLAYLIST_NONE) return; PlayList playlist = GetPlaylist(_currentPlayList); if (playlist.Count <= 0) return; int iItem = _currentItem; iItem++; if (iItem >= playlist.Count) { if (!_repeatPlayList) { _currentPlayList = PlayListType.PLAYLIST_NONE; return; } iItem = 0; } if (m_bIsExternalPlayer && externalPlayerStopped) return; if (!Play(iItem)) { if (!mvPlayer.Playing) { PlayNext(); } } }
protected override void OnPageLoad() { base.OnPageLoad(); if (string.IsNullOrEmpty(playlistname)) { GUIPropertyManager.SetProperty("#currentmodule", "Playlist"); } else { GUIPropertyManager.SetProperty("#currentmodule", "Playlist/" + playlistname); } _playlistType = PlayListType.PLAYLIST_MUSIC_VIDEO; currentView = View.PlayList; facadeView.CurrentLayout = GUIFacadeControl.Layout.Playlist; LoadDirectory(string.Empty); if (m_iItemSelected >= 0) { GUIControl.SelectItemControl(GetID, facadeView.GetID, m_iItemSelected); } if ((m_iLastControl == facadeView.GetID) && facadeView.Count <= 0) { m_iLastControl = btnNowPlaying.GetID; GUIControl.FocusControl(GetID, m_iLastControl); } if (facadeView.Count <= 0) { GUIControl.FocusControl(GetID, btnViewAs.GetID); } using (MediaPortal.Profile.Settings settings = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { playlistPlayer.RepeatPlaylist = settings.GetValueAsBool("youtubeplaylist", "repeat", true); ScrobblerOn = settings.GetValueAsBool("youtubeplaylist", "ScrobblerOn", true); currentScrobbleMode =(ScrobbleMode) settings.GetValueAsInt("youtubeplaylist", "ScrobblerMode", 0); } if (btnRepeatPlaylist != null) { btnRepeatPlaylist.Selected = playlistPlayer.RepeatPlaylist; } if (ScrobblerOn) btnScrobble.Selected = true; SetScrobbleButonLabel(); SelectCurrentPlayingSong(); }
void playlistPlayer_PlaylistChanged(PlayListType nPlayList, PlayList playlist) { if (null != bw && nPlayList == GetPlayListType() && !ignorePlaylistChange && bw.IsBusy && !bw.CancellationPending) bw.CancelAsync(); }
public void OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED: { PlayListItem item = GetCurrentItem(); if (item != null) { if (item.Type != PlayListItem.PlayListItemType.AudioStream) { if (!Player.g_Player.IsPicturePlaylist) { Reset(); _currentPlayList = PlayListType.PLAYLIST_NONE; } else { Player.g_Player.IsPicturePlaylist = false; } } } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } break; // Allows a Musicplayer to continuously play // Note: BASS Player uses a different technique now, because of Gapless Playback // The handling of the message is left for backward compatibility with 3rd party plugins case GUIMessage.MessageType.GUI_MSG_PLAYBACK_CROSSFADING: { PlayNext(); } break; case GUIMessage.MessageType.GUI_MSG_PLAYBACK_ENDED: { // This message is sent by both the internal and BASS player // In case of gapless/crossfading it is only sent after the last song PlayNext(false); if (!g_Player.Playing) { g_Player.Release(); // Clear focus when playback ended GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } } break; case GUIMessage.MessageType.GUI_MSG_PLAY_FILE: { Log.Info("Playlistplayer: Start file ({0})", message.Label); g_Player.Play(message.Label); if (!g_Player.Playing) { g_Player.Stop(); } } break; case GUIMessage.MessageType.GUI_MSG_STOP_FILE: { Log.Info("Playlistplayer: Stop file"); g_Player.Stop(); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_PERCENTAGE: { Log.Info("Playlistplayer: SeekPercent ({0}%)", message.Param1); g_Player.SeekAsolutePercentage(message.Param1); Log.Debug("Playlistplayer: SeekPercent ({0}%) done", message.Param1); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_END: { double duration = g_Player.Duration; double position = g_Player.CurrentPosition; if (position < duration - 1d) { Log.Info("Playlistplayer: SeekEnd ({0})", duration); g_Player.SeekAbsolute(duration - 2d); Log.Debug("Playlistplayer: SeekEnd ({0}) done", g_Player.CurrentPosition); } } break; case GUIMessage.MessageType.GUI_MSG_SEEK_POSITION: { g_Player.SeekAbsolute(message.Param1); } break; } }
// Play all files in selected directory private void OnPlayAll(string path) { // Get all video files in selected folder and it's subfolders ArrayList playFiles = new ArrayList(); AddVideoFiles(path, ref playFiles); if(playFiles.Count == 0) { return; } int selectedOption = 0; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); // Check and play according to setting value if (_howToPlayAll == 3) // Ask, select sort method from options in GUIDialogMenu { if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu dlg.AddLocalizedString(103); // By Name dlg.AddLocalizedString(104); // By Date dlg.AddLocalizedString(191); // Shuffle // Show GUIDialogMenu dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } selectedOption = dlg.SelectedId; } else // Don't ask, sort according to setting and play videos { selectedOption = _howToPlayAll; } // Get current playlist _currentPlaylistType = new PlayListType(); _currentPlaylistType = _playlistPlayer.CurrentPlaylistType; _currentPlaylistIndex = _playlistPlayer.CurrentSong; // Reset playlist _playlistPlayer.Reset(); _playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_VIDEO; PlayList tmpPlayList = _playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_VIDEO); tmpPlayList.Clear(); // Do sorting switch (selectedOption) { // // ****** Watch out for fallthrough of empty cases if reordering CASE ******* // case 0: // By name == 103 case 103: AddToPlayList(tmpPlayList, playFiles.ToArray()); List<PlayListItem> sortedPlayListItems = new List<PlayListItem>(); sortedPlayListItems.AddRange(tmpPlayList); sortedPlayListItems.Sort((item1, item2) => StringLogicalComparer.Compare(item1.Description, item2.Description)); tmpPlayList.Clear(); foreach (PlayListItem playListItem in sortedPlayListItems) { tmpPlayList.Add(playListItem); } break; case 1: // By date (date modified) == 104 case 104: IOrderedEnumerable<object> sortedPlayList = playFiles.ToArray().OrderBy(fn => new FileInfo((string)fn).LastWriteTime); AddToPlayList(tmpPlayList, sortedPlayList); break; case 2: // Shuffle == 191 case 191: AddToPlayList(tmpPlayList, playFiles.ToArray()); tmpPlayList.Shuffle(); break; } // Play movies PlayMovieFromPlayList(false, true); }
public PlayList GetPlaylist(PlayListType nPlayList) { switch (nPlayList) { case PlayListType.PLAYLIST_TVSERIES: return _tvseriesPlayList; default: _emptyPlayList.Clear(); return _emptyPlayList; } }
/// <summary> /// Save player state (when form was resized) /// </summary> protected void SavePlayerState() { if (!_wasPlayingVideo && (g_Player.Playing && (g_Player.IsTV || g_Player.IsVideo || g_Player.IsDVD))) { _wasPlayingVideo = true; // Some Audio/video is playing _currentPlayerPos = g_Player.CurrentPosition; _currentPlayListType = PlaylistPlayer.CurrentPlaylistType; _currentPlayList = new PlayList(); Log.Info("D3D: Saving fullscreen state for resume: {0}", Menu == null); var tempList = PlaylistPlayer.GetPlaylist(_currentPlayListType); if (tempList.Count == 0 && g_Player.IsDVD) { // DVD is playing var itemDVD = new PlayListItem {FileName = g_Player.CurrentFile, Played = true, Type = PlayListItem.PlayListItemType.DVD}; tempList.Add(itemDVD); } foreach (var itemNew in tempList) { _currentPlayList.Add(itemNew); } _currentFile = PlaylistPlayer.Get(PlaylistPlayer.CurrentSong); if (_currentFile.Equals(string.Empty) && g_Player.IsDVD) { _currentFile = g_Player.CurrentFile; } Log.Info("D3D: Stopping media - Current playlist: Type: {0} / Size: {1} / Current item: {2} / Filename: {3} / Position: {4}", _currentPlayListType, _currentPlayList.Count, PlaylistPlayer.CurrentSong, _currentFile, _currentPlayerPos); g_Player.Stop(); _lastActiveWindow = GUIWindowManager.ActiveWindow; } }
public PlayList GetPlaylist(PlayListType nPlayList) { switch (nPlayList) { case PlayListType.PLAYLIST_MVCENTRAL: return _mvCentralPlayList; default: _emptyPlayList.Clear(); return _emptyPlayList; } }
public void OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED: { PlayListItem item = GetCurrentItem(); if (item != null) { // notify listeners if( EpisodeStopped != null) EpisodeStopped(item.Episode); Reset(); _currentPlayList = PlayListType.PLAYLIST_NONE; SetProperties(item, true); } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } break; case GUIMessage.MessageType.GUI_MSG_PLAYBACK_ENDED: { SetAsWatched(); PlayNext(); if (!g_Player.Playing) { g_Player.Release(); // Clear focus when playback ended GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } } break; case GUIMessage.MessageType.GUI_MSG_PLAY_FILE: { MPTVSeriesLog.Write(string.Format("Playlistplayer: Start file ({0})", message.Label)); g_Player.Play(message.Label); if (!g_Player.Playing) g_Player.Stop(); } break; case GUIMessage.MessageType.GUI_MSG_STOP_FILE: { MPTVSeriesLog.Write(string.Format("Playlistplayer: Stop file")); g_Player.Stop(); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_PERCENTAGE: { MPTVSeriesLog.Write(string.Format("Playlistplayer: SeekPercent ({0}%)", message.Param1)); g_Player.SeekAsolutePercentage(message.Param1); MPTVSeriesLog.Write(string.Format("Playlistplayer: SeekPercent ({0}%) done", message.Param1),MPTVSeriesLog.LogLevel.Debug); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_END: { double duration = g_Player.Duration; double position = g_Player.CurrentPosition; if (position < duration - 1d) { MPTVSeriesLog.Write(string.Format("Playlistplayer: SeekEnd ({0})", duration)); g_Player.SeekAbsolute(duration - 2d); MPTVSeriesLog.Write(string.Format("Playlistplayer: SeekEnd ({0}) done", g_Player.CurrentPosition),MPTVSeriesLog.LogLevel.Debug); } } break; case GUIMessage.MessageType.GUI_MSG_SEEK_POSITION: { g_Player.SeekAbsolute(message.Param1); } break; } }
/// <summary> /// Deal with GUI messages /// </summary> /// <param name="message"></param> public void OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED: { PlayListItem item = GetCurrentItem(); if (item != null) { // when skipping video with Prev or Next the stopped message is received but as skipping // we do not want to treat this as a stop whcih resets and clears the playlist // the skipTrackActive bool is set before playNext of playPrevious methods are called and we check this // and only clear the playlist down if not true. if (skipTrackActive) skipTrackActive = false; else { Reset(); _currentPlayList = PlayListType.PLAYLIST_NONE; SetProperties(item, true); } if (item != null && mvCentralCore.Settings.SubmitOnLastFM) ScrobbleSubmit(item); } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } break; case GUIMessage.MessageType.GUI_MSG_PLAYBACK_ENDED: { PlayListItem item = GetCurrentItem(); SetAsWatched(); SetProperties(item, true); if (item != null && mvCentralCore.Settings.SubmitOnLastFM) ScrobbleSubmit(item); PlayNext(); if (!mvPlayer.Playing) { logger.Debug("After GUI_MSG_PLAYBACK_ENDED g_Player.Playing is false"); mvPlayer.Release(); // Clear focus when playback ended GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS, 0, 0, 0, -1, 0, null); GUIGraphicsContext.SendMessage(msg); } } break; case GUIMessage.MessageType.GUI_MSG_PLAY_FILE: { logger.Debug(string.Format("Playlistplayer: Start file ({0})", message.Label)); // Play the file _currentPlayList = PlayListType.PLAYLIST_MVCENTRAL; mvPlayer.Play(message.Label); } break; case GUIMessage.MessageType.GUI_MSG_STOP_FILE: { logger.Debug(string.Format("Playlistplayer: Stop file")); mvPlayer.Stop(); _currentPlayList = PlayListType.PLAYLIST_NONE; PlayListItem item = GetCurrentItem(); if (item != null && mvCentralCore.Settings.SubmitOnLastFM) ScrobbleSubmit(item); SetProperties(item, true); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_PERCENTAGE: { logger.Info(string.Format("Playlistplayer: SeekPercent ({0}%)", message.Param1)); mvPlayer.SeekAsolutePercentage(message.Param1); logger.Debug(string.Format("Playlistplayer: SeekPercent ({0}%) done", message.Param1)); } break; case GUIMessage.MessageType.GUI_MSG_SEEK_FILE_END: { double duration = mvPlayer.Duration; double position = mvPlayer.CurrentPosition; if (position < duration - 1d) { logger.Info(string.Format("Playlistplayer: SeekEnd ({0})", duration)); mvPlayer.SeekAbsolute(duration - 2d); logger.Debug(string.Format("Playlistplayer: SeekEnd ({0}) done", mvPlayer.CurrentPosition)); } } break; case GUIMessage.MessageType.GUI_MSG_SEEK_POSITION: { mvPlayer.SeekAbsolute(message.Param1); } break; } }