private void LoadSongsFromFolder(string startfile, string folder, bool includeSubFolders) { using (Settings xmlreader = new MPSettings()) { _stripArtistPrefixes = xmlreader.GetValueAsBool("musicfiles", "stripartistprefixes", false); } // clear current playlist playlistPlayer = MediaPortal.Playlists.PlayListPlayer.SingletonPlayer; //playlistPlayer.GetPlaylist(MediaPortal.Playlists.PlayListType.PLAYLIST_VIDEO_TEMP).Clear(); playlistPlayer.GetPlaylist(MediaPortal.Playlists.PlayListType.PLAYLIST_MUSIC_VIDEO).Clear(); int numSongs = 0; try { List <string> files = new List <string>(); files.Add(startfile); GetFiles(folder, ref files, includeSubFolders); List <string> unique = files.Distinct().ToList(); foreach (string file in unique) { if (IsMusicFile(file)) { MediaPortal.Playlists.PlayListItem item = new MediaPortal.Playlists.PlayListItem(); item.FileName = file; item.Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.Video; /* * MusicTag tag = TagReader.ReadTag(file); * if (tag != null) * { * tag.Artist = MediaPortal.Util.Utils.FormatMultiItemMusicStringTrim(tag.Artist, _stripArtistPrefixes); * tag.AlbumArtist = MediaPortal.Util.Utils.FormatMultiItemMusicStringTrim(tag.AlbumArtist, _stripArtistPrefixes); * tag.Genre = MediaPortal.Util.Utils.FormatMultiItemMusicStringTrim(tag.Genre, false); * tag.Composer = MediaPortal.Util.Utils.FormatMultiItemMusicStringTrim(tag.Composer, _stripArtistPrefixes); * item.Description = tag.Title; * item.MusicTag = tag; * item.Duration = tag.Duration; * } */ playlistPlayer.GetPlaylist(MediaPortal.Playlists.PlayListType.PLAYLIST_MUSIC_VIDEO).Add(item); numSongs++; } } } catch //(Exception ex) { logger.Error("Error retrieving songs from folder."); } }
public VideoHandler() { playlistPlayer = MediaPortal.Playlists.PlayListPlayer.SingletonPlayer; // Check if External Player is being used MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")); m_bIsExternalPlayer = !xmlreader.GetValueAsBool("movieplayer", "internal", true); m_bIsExternalDVDPlayer = !xmlreader.GetValueAsBool("dvdplayer", "internal", true); // external player handlers Utils.OnStartExternal += new Utils.UtilEventHandler(onStartExternal); Utils.OnStopExternal += new Utils.UtilEventHandler(onStopExternal); g_Player.PlayBackStopped += new MediaPortal.Player.g_Player.StoppedHandler(OnPlayBackStopped); g_Player.PlayBackEnded += new MediaPortal.Player.g_Player.EndedHandler(OnPlayBackEnded); g_Player.PlayBackStarted += new MediaPortal.Player.g_Player.StartedHandler(OnPlayBackStarted); g_Player.PlayBackChanged += new g_Player.ChangedHandler(OnPlaybackChanged); GUIVideoOverlay.SetGuiPropertiesUpdate += new GUIVideoOverlay.SetGuiProperties(SetGuiPropertiesUpdate); PlayPropertyUpdater.WorkerSupportsCancellation = true; PlayPropertyUpdater.DoWork += new DoWorkEventHandler(SetPlayProperties_DoWork); }