private void button10_Click(object sender, EventArgs e) { var station = new RadioTimeStation(); station.Grabber = grabber; station.Get("s109401"); //if (listView1.SelectedItems.Count > 0) //{ // StationGetRequest req = new StationGetRequest(); // int i = 0; // req.StationId = ((RadioTimeOutline)listView1.SelectedItems[0].Tag).StationIdAsInt; // propertyGrid1.SelectedObject = websrv.Station_Get(req); // MessageBox.Show("Test"); //} }
/// <summary> /// Does the play. /// </summary> /// <param name="item">The item.</param> public void DoPlay(RadioTimeOutline item) { ShowWaitCursor(); try { _station = null; _nowPlaying = null; _show = null; _currentItem = null; if (item == null || string.IsNullOrEmpty(item.GuidId)) { ErrMessage(Translation.StationNotAvaiable); return; } PlayGuidId = item.GuidId ; _currentItem = item.Clone(); //RadioTimeStation station = Settings.NowPlayingStation; _station = new RadioTimeStation(); _station.Grabber = grabber; _station.Get(PlayGuidId); if (_station.IsAvailable) { //var nowPlaying = Settings.NowPlaying; _nowPlaying = new RadioTimeNowPlaying(); _nowPlaying.Grabber = grabber; _nowPlaying.Get(PlayGuidId, _station.HasSong); if (_nowPlaying.IsShow && !string.IsNullOrEmpty(_nowPlaying.ShowGuidId)) { _show = new RadioTimeShow(); _show.Grabber = grabber; _show.Get(_nowPlaying.ShowGuidId) ; } var playerType = PlayerType.Video; if (_setting.FormatPlayer.ContainsKey(item.Formats)) playerType = _setting.FormatPlayer[item.Formats]; try { var playList = new PlayList(); //if (item.Url.ToLower().Contains(".pls") || item.Url.ToLower().Contains(".m3u") || item.Url.ToLower().Contains(".asx")) { var TargetFile = Path.GetTempFileName(); var client = new WebClient(); try { if (item.Url.ToLower().Contains(".pls")) { client.DownloadFile(item.Url, TargetFile); IPlayListIO loader = new PlayListPLSEIO(); loader.Load(playList, TargetFile); } else if (item.Url.ToLower().Contains(".asx")) { client.DownloadFile(item.Url, TargetFile); IPlayListIO loader = new PlayListASXIO(); loader.Load(playList, TargetFile); } else { client.DownloadFile(item.Url, TargetFile); IPlayListIO loader = new PlayListM3uIO(); loader.Load(playList, TargetFile); } } finally { client.Dispose(); File.Delete(TargetFile); } //if (playList.Count > 0 && playList[0].FileName.ToLower().StartsWith("http") && playList[0].FileName.ToLower().Contains(".m3u")) //{ // client.DownloadFile(playList[0].FileName, TargetFile); // IPlayListIO loader1 = new PlayListM3uIO(); // loader1.Load(playList, TargetFile); // File.Delete(TargetFile); //} TargetFile = Path.GetTempFileName(); client = new WebClient(); try { if (playList.Count > 0 && playList[0].FileName.ToLower().Contains(".pls")) { client.DownloadFile(playList[0].FileName, TargetFile); IPlayListIO loader1 = new PlayListPLSEIO(); loader1.Load(playList, TargetFile); } if (playList.Count > 0 && playList[0].FileName.ToLower().Contains(".asx")) { client.DownloadFile(playList[0].FileName, TargetFile); IPlayListIO loader1 = new PlayListASXIO(); loader1.Load(playList, TargetFile); } if (playList.Count > 0 && playList[0].FileName.ToLower().Contains(".m3u")) { client.DownloadFile(playList[0].FileName, TargetFile); IPlayListIO loader1 = new PlayListM3uIO(); loader1.Load(playList, TargetFile); if (playList.Count == 0) { IPlayListIO loader2 = new PlayListPLSEIO(); loader2.Load(playList, TargetFile); } } } finally { client.Dispose(); File.Delete(TargetFile); } } if (playList.Count > 0) _currentFileName = playList[0].FileName; else _currentFileName = item.Url; switch (playerType) { case PlayerType.Audio: ClearPlayProps(); g_Player.PlayAudioStream(_currentFileName); return; case PlayerType.Video: // test if the station have tv group ClearPlayProps(); if (item.GenreId == "g260" || item.GenreId == "g83" || item.GenreId == "g374" || item.GenreId == "g2769") g_Player.PlayVideoStream(_currentFileName); else g_Player.Play(_currentFileName, g_Player.MediaType.Unknown); return; case PlayerType.Unknow: return; default: return; } // moved to PLAYBACKSTARTED EVENT //if (isPlaying && g_Player.CurrentFile == playList[0].FileName) } catch (Exception exception) { _currentItem = null; ErrMessage(string.Format(Translation.PlayError, exception.Message)); return; } } } finally { HideWaitCursor(); } ErrMessage(Translation.StationNotAvaiable); return; }
protected void ClearInternalVariables() { _currentFileName = string.Empty; _currentItem = null; _nowPlaying = null; _station = null; _show = null; }
public void UpdatePlayProps() { // Log.Debug("*** UpdatePlayProps"); try { if (!g_Player.Playing) { return; } PlayGuidId = (string.IsNullOrEmpty(PlayGuidId)) ? GUIPropertyManager.GetProperty("#RadioTime.Play.GuidId") : PlayGuidId; if (string.IsNullOrEmpty(PlayGuidId)) { return; } _station = new RadioTimeStation(); _station.Grabber = grabber; _station.Get(PlayGuidId); if (!string.IsNullOrEmpty(PlayGuidId) && _station.IsAvailable) { //var nowPlaying = Settings.NowPlaying; _nowPlaying = new RadioTimeNowPlaying(); _nowPlaying.Grabber = grabber; _nowPlaying.Get(PlayGuidId, _station.HasSong); // if (_nowPlaying.IsShow && !string.IsNullOrEmpty(_nowPlaying.ShowGuidId)) { _show = new RadioTimeShow(); _show.Grabber = grabber; _show.Get(_nowPlaying.ShowGuidId) ; } // Settings.NowPlaying = _nowPlaying.Clone(); Settings.NowPlayingStation = _station.Clone(); if (_show != null) { Settings.NowPlayingShow = _show.Clone(); } else { Settings.NowPlayingShow = null; } // UpdateProps(); } } catch (Exception ex) { Log.Debug("UpdatePlayProps: " + ex.Message); } }
public RadioTimeStation Clone() { RadioTimeStation returnStation = (RadioTimeStation)this.MemberwiseClone(); return(returnStation); }
protected override void OnShowContextMenu() { GUIListItem selectedItem = listControl.SelectedListItem; if (selectedItem != null) { if (selectedItem.Label != ".." && selectedItem.MusicTag != null && !selectedItem.IsFolder) { try { var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) return; dlg.Reset(); dlg.SetHeading(498); // menu RadioTimeStation station = new RadioTimeStation { Grabber = grabber }; station.Get(((RadioTimeOutline)selectedItem.MusicTag).GuidId); bool show = false; if (station.IsPreset) { dlg.Add(Translation.RemoveFromFavorites); show = true; } else { dlg.Add(Translation.AddToFavorites); show = true; } if (station.HasSchedule) { dlg.Add(Translation.ShowGiuide); show = true; } if (!show) return; dlg.DoModal(GetID); if (dlg.SelectedId == -1) return; if (dlg.SelectedLabelText == Translation.AddToFavorites) AddToFavorites(((RadioTimeOutline)selectedItem.MusicTag).GuidId); if (dlg.SelectedLabelText == Translation.RemoveFromFavorites) RemoveFavorites(((RadioTimeOutline)selectedItem.MusicTag).PresetId); if (dlg.SelectedLabelText == Translation.ShowGiuide) { MiniGuide miniGuide = (MiniGuide)GUIWindowManager.GetWindow(25651); miniGuide.GuidId = ((RadioTimeOutline)selectedItem.MusicTag).GuidId; miniGuide.grabber = new RadioTime(); miniGuide.grabber.Settings = grabber.Settings; miniGuide.DoModal(GetID); } } catch (System.Web.Services.Protocols.SoapException ex) { Log.Error("[RadioTime] Comunication error or wrong user name or password "); Log.Error(ex); } } } }