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); } } }
private void btPlaylistLoad_Click(object sender, EventArgs e) { OpenFileDialog oFD = new OpenFileDialog(); oFD.Filter = "M3U Format (*.m3u)|*.m3u|Winamp Playlist (*.pls)|*.pls"; if (oFD.ShowDialog() == DialogResult.OK) { IPlayListIO loader = PlayListFactory.CreateIO(oFD.FileName); loader.Load(_player.PlayList, oFD.FileName); } }
private void btnPlaylist_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.AddExtension = false; dlg.CheckFileExists = true; dlg.CheckPathExists = true; dlg.Filter = "playlists (*.m3u;*.pls;*.b4s;*.wpl)|*.m3u;*.pls;*.b4s;*.wpl"; dlg.Multiselect = false; dlg.Title = "Select the playlist file to import"; if (dlg.ShowDialog(this) != DialogResult.OK) { return; } IPlayListIO listIO = PlayListFactory.CreateIO(dlg.FileName); PlayList playlist = new PlayList(); if (!listIO.Load(playlist, dlg.FileName)) { MessageBox.Show("There was an error parsing the playlist file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TvBusinessLayer layer = new TvBusinessLayer(); int iInserted = 0; foreach (PlayListItem item in playlist) { if (string.IsNullOrEmpty(item.FileName)) { continue; } if (string.IsNullOrEmpty(item.Description)) { item.Description = item.FileName; } Channel channel = new Channel(true, false, 0, Schedule.MinSchedule, false, Schedule.MinSchedule, 10000, true, "", item.Description, 10000); channel.Persist(); layer.AddWebStreamTuningDetails(channel, item.FileName, 0); layer.AddChannelToRadioGroup(channel, TvConstants.RadioGroupNames.AllChannels); iInserted++; } MessageBox.Show("Imported " + iInserted + " new channels from playlist"); OnSectionActivated(); }
public IEnumerable <WebPlaylistItem> GetPlaylistItems(string playlistId) { PlayList mpPlaylist = new PlayList(); string path = GetPlaylistPath(playlistId); IPlayListIO factory = PlayListFactory.CreateIO(path); if (factory.Load(mpPlaylist, path)) { List <WebPlaylistItem> retList = new List <WebPlaylistItem>(); foreach (PlayListItem i in mpPlaylist) { WebPlaylistItem webItem = new WebPlaylistItem(); WebMusicTrackBasic track = LoadAllTracks <WebMusicTrackBasic>().FirstOrDefault(x => x.Path.Contains(i.FileName)); webItem.Title = i.Description; webItem.Duration = i.Duration; webItem.Path = new List <String>(); webItem.Path.Add(i.FileName); if (track != null) { webItem.Id = track.Id; webItem.Type = track.Type; webItem.DateAdded = track.DateAdded; } else { Log.Warn("Couldn't get track information for " + i.FileName); } retList.Add(webItem); } return(retList); } else if (new FileInfo(path).Length == 0) { // for newly created playlists, return an empty list, to make sure that a CreatePlaylist call followed by an AddItem works return(new List <WebPlaylistItem>()); } else { Log.Warn("Couldn't load playlist {0}", playlistId); return(null); } }
public IEnumerable <WebPlaylistItem> GetPlaylistItems(string playlistId) { PlayList mpPlaylist = new PlayList(); string path = GetPlaylistPath(playlistId); IPlayListIO factory = PlayListFactory.CreateIO(path); if (factory.Load(mpPlaylist, path)) { var tracks = LoadAllTracks <WebMusicTrackBasic>().ToList(); return(mpPlaylist .Select(x => { var track = tracks.FirstOrDefault(t => t.Path.Contains(x.FileName)); return new WebPlaylistItem() { Title = x.Description, Duration = x.Duration, Path = new List <string>() { x.FileName }, Type = WebMediaType.MusicTrack, Id = track != null ? track.Id : null, DateAdded = track != null ? track.DateAdded : new DateTime(1970, 1, 1), Artwork = track != null ? track.Artwork : new List <WebArtwork>(), }; }) .ToList()); } else if (new FileInfo(path).Length == 0) { // for newly created playlists, return an empty list, to make sure that a CreatePlaylist call followed by an AddItem works return(new List <WebPlaylistItem>()); } else { Log.Warn("Couldn't load playlist {0}", playlistId); return(null); } }
public void DoWork() { var layer = new TvBusinessLayer(); _defaultTVGroup = layer.GetSetting("DVBIPScanUtilPluginSetupDefaultGroup", "New").Value; String EPGUtilPluginTuningXML = layer.GetSetting("DVBIPScanUtilPluginSetupTuningXML", "").Value; if (EPGUtilPluginTuningXML == "") { Log.Error("DVBIPScanUtilPlugin: missing tuning config"); return; } IPlayListIO playlistIO = PlayListFactory.CreateIO(String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath, EPGUtilPluginTuningXML)); playlistIO.Load(playlist, String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath, EPGUtilPluginTuningXML)); if (playlist.Count == 0) { return; } IList <Card> dbsCards = Card.ListAll(); foreach (Card card in dbsCards) { if (CardType.DvbIP == RemoteControl.Instance.Type(card.IdCard)) { Log.Debug("DoScan card: " + card.IdCard); _cardNumber = card.IdCard; DoScan(); } } }
private WebPlaylist GetPlaylist(string path) { PlayList mpPlaylist = new PlayList(); IPlayListIO factory = PlayListFactory.CreateIO(path); if (factory.Load(mpPlaylist, path)) { WebPlaylist webPlaylist = new WebPlaylist() { Id = EncodeTo64(Path.GetFileName(path)), Title = mpPlaylist.Name, Path = new List <string>() { path } }; webPlaylist.ItemCount = mpPlaylist.Count; return(webPlaylist); } else { Log.Warn("Couldn't parse playlist " + path); return(null); } }
private void DoScan() { int tvChannelsNew = 0; int radioChannelsNew = 0; int tvChannelsUpdated = 0; int radioChannelsUpdated = 0; string buttonText = mpButtonScanTv.Text; IUser user = new User(); user.CardId = _cardNumber; try { // First lock the card, because so that other parts of a hybrid card can't be used at the same time _isScanning = true; _stopScanning = false; mpButtonScanTv.Text = "Cancel..."; RemoteControl.Instance.EpgGrabberEnabled = false; listViewStatus.Items.Clear(); PlayList playlist = new PlayList(); if (mpComboBoxService.SelectedIndex == 0) { //TODO read SAP announcements } else { IPlayListIO playlistIO = PlayListFactory.CreateIO(String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath, mpComboBoxService.SelectedItem)); playlistIO.Load(playlist, String.Format(@"{0}\TuningParameters\dvbip\{1}.m3u", PathManager.GetDataPath, mpComboBoxService.SelectedItem)); } if (playlist.Count == 0) { return; } mpComboBoxService.Enabled = false; checkBoxCreateGroups.Enabled = false; checkBoxEnableChannelMoveDetection.Enabled = false; TvBusinessLayer layer = new TvBusinessLayer(); Card card = layer.GetCardByDevicePath(RemoteControl.Instance.CardDevice(_cardNumber)); int index = -1; IEnumerator <PlayListItem> enumerator = playlist.GetEnumerator(); while (enumerator.MoveNext()) { if (_stopScanning) { return; } index++; float percent = ((float)(index)) / playlist.Count; percent *= 100f; if (percent > 100f) { percent = 100f; } progressBar1.Value = (int)percent; string url = enumerator.Current.FileName.Substring(enumerator.Current.FileName.LastIndexOf('\\') + 1); string name = enumerator.Current.Description; DVBIPChannel tuneChannel = new DVBIPChannel(); tuneChannel.Url = url; tuneChannel.Name = name; string line = String.Format("{0}- {1} - {2}", 1 + index, tuneChannel.Name, tuneChannel.Url); ListViewItem item = listViewStatus.Items.Add(new ListViewItem(line)); item.EnsureVisible(); RemoteControl.Instance.Tune(ref user, tuneChannel, -1); IChannel[] channels; channels = RemoteControl.Instance.Scan(_cardNumber, tuneChannel); UpdateStatus(); if (channels == null || channels.Length == 0) { if (RemoteControl.Instance.TunerLocked(_cardNumber) == false) { line = String.Format("{0}- {1} :No Signal", 1 + index, tuneChannel.Url); item.Text = line; item.ForeColor = Color.Red; continue; } else { line = String.Format("{0}- {1} :Nothing found", 1 + index, tuneChannel.Url); item.Text = line; item.ForeColor = Color.Red; continue; } } int newChannels = 0; int updatedChannels = 0; for (int i = 0; i < channels.Length; ++i) { Channel dbChannel; DVBIPChannel channel = (DVBIPChannel)channels[i]; if (channels.Length > 1) { if (channel.Name.IndexOf("Unknown") == 0) { channel.Name = name + (i + 1); } } else { channel.Name = name; } bool exists; TuningDetail currentDetail; //Check if we already have this tuningdetail. According to DVB-IP specifications there are two ways to identify DVB-IP //services: one ONID + SID based, the other domain/URL based. At this time we don't fully and properly implement the DVB-IP //specifications, so the safest method for service identification is the URL. The user has the option to enable the use of //ONID + SID identification and channel move detection... if (checkBoxEnableChannelMoveDetection.Checked) { currentDetail = layer.GetTuningDetail(channel.NetworkId, channel.ServiceId, TvBusinessLayer.GetChannelType(channel)); } else { currentDetail = layer.GetTuningDetail(channel.Url, TvBusinessLayer.GetChannelType(channel)); } if (currentDetail == null) { //add new channel exists = false; dbChannel = layer.AddNewChannel(channel.Name, channel.LogicalChannelNumber); dbChannel.SortOrder = 10000; if (channel.LogicalChannelNumber >= 1) { dbChannel.SortOrder = channel.LogicalChannelNumber; } dbChannel.IsTv = channel.IsTv; dbChannel.IsRadio = channel.IsRadio; dbChannel.Persist(); } else { exists = true; dbChannel = currentDetail.ReferencedChannel(); } layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels); if (checkBoxCreateGroups.Checked) { layer.AddChannelToGroup(dbChannel, channel.Provider); } if (currentDetail == null) { layer.AddTuningDetails(dbChannel, channel); } else { //update tuning details... TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail); td.Persist(); } if (channel.IsTv) { if (exists) { tvChannelsUpdated++; updatedChannels++; } else { tvChannelsNew++; newChannels++; } } if (channel.IsRadio) { if (exists) { radioChannelsUpdated++; updatedChannels++; } else { radioChannelsNew++; newChannels++; } } layer.MapChannelToCard(card, dbChannel, false); line = String.Format("{0}- {1} :New:{2} Updated:{3}", 1 + index, tuneChannel.Name, newChannels, updatedChannels); item.Text = line; } } //DatabaseManager.Instance.SaveChanges(); } catch (Exception ex) { Log.Write(ex); } finally { RemoteControl.Instance.StopCard(user); RemoteControl.Instance.EpgGrabberEnabled = true; progressBar1.Value = 100; mpComboBoxService.Enabled = true; checkBoxCreateGroups.Enabled = true; checkBoxEnableChannelMoveDetection.Enabled = true; mpButtonScanTv.Text = buttonText; _isScanning = false; } ListViewItem lastItem = listViewStatus.Items.Add(new ListViewItem("Scan done...")); lastItem = listViewStatus.Items.Add( new ListViewItem(String.Format("Total radio channels new:{0} updated:{1}", radioChannelsNew, radioChannelsUpdated))); lastItem = listViewStatus.Items.Add( new ListViewItem(String.Format("Total tv channels new:{0} updated:{1}", tvChannelsNew, tvChannelsUpdated))); lastItem.EnsureVisible(); }
protected void LoadPlayList(string strPlayList) { IPlayListIO loader = PlayListFactory.CreateIO(strPlayList); if (loader == null) { return; } PlayList playlist = new PlayList(); if (!loader.Load(playlist, strPlayList)) { TVSeriesPlugin.ShowDialogOk(Translation.Playlist, new string[] { GUILocalizeStrings.Get(477) }); return; } playlistPlayer.CurrentPlaylistName = System.IO.Path.GetFileNameWithoutExtension(strPlayList); if (playlist.Count == 1 && playlistPlayer.PlaylistAutoPlay) { MPTVSeriesLog.Write(string.Format("GUITVSeriesPlaylist: play single playlist item - {0}", playlist[0].FileName)); // 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, false)) { return; } } 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 start playing it if (playlistPlayer.PlaylistAutoPlay) { playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_TVSERIES; playlistPlayer.Reset(); playlistPlayer.Play(0); } // and activate the playlist window if its not activated yet if (GetID == GUIWindowManager.ActiveWindow) { GUIWindowManager.ActivateWindow(GetID); } } }
/// <summary> /// Loads a new Directory /// </summary> /// <param name="newFolderName">Name of the folder</param> private void LoadDirectory(string newFolderName) { _disableSorting = false; String currentFolder = newFolderName; GUIControl.ClearControl(GetID, facadeView.GetID); List <GUIListItem> itemlist = _mDirectory.GetDirectoryExt(currentFolder); List <GUIListItem> itemfiltered = new List <GUIListItem>(); for (int x = 0; x < itemlist.Count; ++x) { bool addItem = true; GUIListItem item1 = itemlist[x]; for (int y = 0; y < itemlist.Count; ++y) { GUIListItem item2 = itemlist[y]; if (x != y) { if (!item1.IsFolder || !item2.IsFolder) { if (!item1.IsRemote && !item2.IsRemote) { if (Utils.ShouldStack(item1.Path, item2.Path)) { if (String.Compare(item1.Path, item2.Path, true) > 0) { addItem = false; // Update to reflect the stacked size item1.FileInfo.Length += item2.FileInfo.Length; } } } } } } if (addItem) { string label = item1.Label; Utils.RemoveStackEndings(ref label); item1.Label = label; if (_treatPlaylistsAsFolders && PlayListFactory.IsPlayList(item1.Path)) { item1.IsFolder = true; Utils.SetDefaultIcons(item1); } itemfiltered.Add(item1); } } itemlist = itemfiltered; if (_treatPlaylistsAsFolders && PlayListFactory.IsPlayList(newFolderName)) { IPlayListIO loader = PlayListFactory.CreateIO(newFolderName); PlayList playlist = new PlayList(); _disableSorting = true; String basePath = Path.GetDirectoryName(Path.GetFullPath(newFolderName)); if (loader.Load(playlist, newFolderName)) { foreach (PlayListItem plItem in playlist) { GUIListItem item = new GUIListItem { Path = plItem.FileName }; if (plItem.FileName.StartsWith(basePath)) { String mainPath = plItem.FileName.Remove(0, basePath.Length + 1); if (mainPath.StartsWith("cue://") || mainPath.StartsWith("cue://") || mainPath.StartsWith("http://") || mainPath.StartsWith("ftp://") || mainPath.StartsWith("http_proxy://") || mainPath.StartsWith("mms://") || mainPath.StartsWith("mmst://") || mainPath.StartsWith("mpst://") || mainPath.StartsWith("rtsp://") || mainPath.StartsWith("rtp://") || mainPath.StartsWith("sdp://") || mainPath.StartsWith("udp://") || mainPath.StartsWith("unsv://")) { item.Path = mainPath; } } Log.Info("MPlayer GUI: " + item.Path); item.Label = plItem.Description; item.IsFolder = false; Utils.SetDefaultIcons(item); itemlist.Add(item); } } } foreach (GUIListItem item in itemlist) { facadeView.Add(item); } OnSort(); }
/// <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); } } }