public Player() { InitializeComponent(); vlc1.playlist.stop(); // to generate error InvalidCastException on bad VLC version on grid creation vlc1Status = VlcStatus.Preparing; lostRtspRetry = 0; }
private void PrivateStop() { lostTimer.Enabled = false; vlcH = 0; vlcW = 0; vlc1.playlist.stop(); isSoundPresent = false; vlc1Status = VlcStatus.Stopped; }
private VlcMonitor(Label statusLabel, ShutdauwnForm shutdawunForm) { this.monitorRunning = true; this.statusLabel = statusLabel; this.vlcStatus = VlcStatus.MediaStopped; VlcMonitor.instance = this; this.shutdawunForm = shutdawunForm; this.monitorVlc(statusLabel); }
private VlcMonitor(Label statusLabel, ShutdauwnForm shutdawunForm) { this.monitorRunning = true; this.statusLabel = statusLabel; this.vlcStatus = VlcStatus.MediaStopped; VlcMonitor.instance = this; this.shutdawunForm = shutdawunForm; this.monitorVlc(statusLabel); }
/// <summary> /// Send a the command to the VLC media player. /// </summary> /// <param name="query">The query to send. If a null query is provided, just an updated status /// will be requested.</param> private async Task SendCommand(string query = null) { HttpResponseMessage response = null; try { response = await client.GetAsync("requests/status.xml" + (query == null ? "" : "?" + query)); } catch (HttpRequestException) { IsConnected = false; ConnectionChanged?.Invoke(this, new EventArgs()); return; } IsConnected = true; if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); try { Status = (VlcStatus)statusSerializer.Deserialize(stream); } catch (Exception e) { Console.WriteLine(e); } StatusUpdated?.Invoke(this, new EventArgs()); } else if (response.StatusCode == HttpStatusCode.Unauthorized) { IsConnected = false; ConnectionChanged?.Invoke(this, new EventArgs()); } else { Console.WriteLine("error: " + response.StatusCode); } }
/// <summary> /// Set the current state of the VLC monitoring, and change the visual status to an appropiate decsription /// </summary> /// <param name="newVlcStatus"></param> private void setStatus(VlcStatus newVlcStatus) { if (newVlcStatus == this.vlcStatus) { return; } this.vlcStatus = newVlcStatus; string status; switch (newVlcStatus) { case VlcStatus.MediaStopped: status = "Media stopped, shutting down"; break; case VlcStatus.Idle: status = "VLC is idle"; break; case VlcStatus.MediaStarted: status = "Media started"; break; case VlcStatus.MediaPlaying: status = "Media is playing"; break; case VlcStatus.NotFound: status = "VLC process not found"; break; default: status = "Unknown VLC event"; break; } VlcMonitor.setStatus(this.statusLabel, status); }
private void Vlc1PositionChanged() { lostTimer.Enabled = false; lostTimer.Enabled = true; if (vlc1Status == VlcStatus.Buffering) { PosChangedTimes++; vlc1.audio.volume = this.volume; // important for user movies if (PosChangedTimes == 10) //>7,<~10 { vlc1Status = VlcStatus.Playing; Invoke(Playing); lostTimer.Interval = lostRtspTimer; if (lostRtspRetry >= lostRtspRetryAlert) { Invoke(LostStreamRestored); } lostRtspRetry = 0; } } else if (vlcH <= 0) { if (vlc1.video.height > 0) { vlcH = vlc1.video.height; vlcW = vlc1.video.width; Invoke(SizeDetected); } else { vlcH -= 1; if (vlcH < -5) { vlcH = 576; vlcW = 704; Invoke(SizeDetected); } } } }
public bool Play() { if (vlc1Status == VlcStatus.Stopped && vlc1.playlist.items.count > 0) { vlc1Status = VlcStatus.Buffering; PosChangedTimes = 0; lostTimer.Interval = lostRtspOnStartTimer; lostTimer.Enabled = true; vlc1.playlist.play(); vlc1.audio.volume = this.volume; // important for user movies Invoke(Buffering); // to disable ghosts: //To switch VLC from HTTP streaming to RTP/RTSP streaming: // //On the VLC media player Tools menu, click Preferences. //In the Simple Preferences dialog box, click Input / Codecs in the contents panel. //In Input & Codecs Settings, in the Network area, change the Live555 stream transport option from HTTP (default) to RTP over RTSP (TCP). //Click Save. // // --rtsp-tcp return(true); } return(false); }
private static VlcStatus ParseStatus(string xmlString) { var status = new VlcStatus(); XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlString); foreach (XmlNode parent in doc.ChildNodes) { if (parent.Name == "root") { foreach (XmlNode node in parent.ChildNodes) { int parseInt = -1; switch (node.Name.ToLowerInvariant()) { case "apiversion": if (int.TryParse(node.InnerText, out parseInt)) { status.ApiVersion = parseInt; } break; case "time": if (int.TryParse(node.InnerText, out parseInt)) { status.Time = parseInt; } break; case "volume": if (int.TryParse(node.InnerText, out parseInt)) { status.Volume = parseInt; } break; case "length": if (int.TryParse(node.InnerText, out parseInt)) { status.Length = parseInt; } break; case "state": status.State = ParseState(node.InnerText); break; case "version": status.Version = node.InnerText; break; case "position": if (double.TryParse(node.InnerText, out double parseDouble)) { status.Position = parseDouble; } break; case "information": status.FileInfo = ParseFileInformation(node); break; default: break; } } } } return(status); }
public async Task <VlcStatus> GetStatus() { PostSubmitter ps = GetSubmiter(baseUrl + "requests/status.xml"); var res = await ps.PostAsync(); XDocument doc = XDocument.Parse(res); //doc.LoadXml(res); VlcStatus result = new VlcStatus(); var fs = XmlHelper.SelectElement(doc.Root, "fullscreen"); if (fs != null) { if (fs.Value == "0") { result.IsFullScreen = false; } else { result.IsFullScreen = Convert.ToBoolean(fs.Value); } } result.AudioDelay = Convert.ToDouble(XmlHelper.SelectElement(doc.Root, "audiodelay").Value); result.SubsDelay = Convert.ToDouble(XmlHelper.SelectElement(doc.Root, "subtitledelay").Value); var state = XmlHelper.SelectElement(doc.Root, "state").Value.Trim(); switch (state) { case "paused": result.State = VlcState.Paused; break; case "playing": result.State = VlcState.Playing; break; default: result.State = VlcState.Stopped; break; } result.VlcVersion = XmlHelper.SelectElement(doc.Root, "version").Value.Trim(); result.Duration = TimeSpan.FromSeconds(Convert.ToInt32(XmlHelper.SelectElement(doc.Root, "length").Value)); result.CurrentPossiton = TimeSpan.FromSeconds(Convert.ToInt32(XmlHelper.SelectElement(doc.Root, "time").Value)); var infos = XmlHelper.SelectElements(doc.Root, "information/category"); foreach (var item in infos) { var name = item.Attribute("name").Value; if (name == "meta") { var serie = XmlHelper.GetNodeByNameAttribute(item, "info", "name", "showName"); if (serie != null) { var titre = XmlHelper.GetNodeByNameAttribute(item, "info", "name", "title"); if (titre != null) { result.CurrentllyPlaying = titre.Value.Trim(); } else { result.CurrentllyPlaying = serie.Value.Trim(); } } else { var fname = XmlHelper.GetNodeByNameAttribute(item, "info", "name", "filename"); if (fname != null) { result.CurrentllyPlaying = fname.Value.Trim(); } else { result.CurrentllyPlaying = ""; } } } if (name.IndexOf(' ') > 0) { //FLUUUUUUXUX VlcFlux flux = new VlcFlux(); flux.Id = int.Parse(name.Split(' ')[1]); for (int i = 0; i < typeNameLoc.Length; i++) { var typeNode = XmlHelper.GetNodeByNameAttribute(item, "info", "name", typeNameLoc[i]); if (typeNode != null) { var typeText = typeNode.Value.Trim(); if (typeNameAudioLoc.Contains(typeText)) { flux.FluxType = FluxType.Audio; break; } else if (typeNameSubsLoc.Contains(typeText)) { flux.FluxType = FluxType.SubTitles; break; } else if (typeNameVidLoc.Contains(typeText)) { flux.FluxType = FluxType.Video; break; } } } result.Fluxs.Add(flux); flux.Name = "Stream " + (from r in result.Fluxs where r.FluxType == flux.FluxType select r).Count(); } } return(result); }
/// <summary> /// Set the current state of the VLC monitoring, and change the visual status to an appropiate decsription /// </summary> /// <param name="newVlcStatus"></param> private void setStatus(VlcStatus newVlcStatus) { if (newVlcStatus == this.vlcStatus) { return; } this.vlcStatus = newVlcStatus; string status; switch (newVlcStatus) { case VlcStatus.MediaStopped: status = "Media stopped, shutting down"; break; case VlcStatus.Idle: status = "VLC is idle"; break; case VlcStatus.MediaStarted: status = "Media started"; break; case VlcStatus.MediaPlaying: status = "Media is playing"; break; case VlcStatus.NotFound: status = "VLC process not found"; break; default: status = "Unknown VLC event"; break; } VlcMonitor.setStatus(this.statusLabel, status); }
private void ClientOnStatusUpdated(object sender, VlcStatus vlcStatus) { var time = new TimeSpan(0, 0, 0, vlcStatus.Time); Task.Factory.StartNew(() => { var currentLeaf = GetCurrentLeaf().Result; if (currentLeaf != null) { RunOnUiThread(() => TimeTextView2.Text = TimeSpan.FromSeconds(currentLeaf.Duration).ToString()); } else { RunOnUiThread(() => TimeTextView2.SetText(Resource.String.app_unknown_duration)); } }); RunOnUiThread(() => { TimeTextView.Text = time.ToString(); var value = (int)Math.Round((decimal)(125.0 * vlcStatus.Volume / 320.0)); if (CanProgressBeSet) { VolumeSeekbar.SetProgress(value, true); } string title; try { title = Path.GetFileNameWithoutExtension(vlcStatus.Information.Category.First().Info .First(i => i.Name == "filename").Text); } catch { try { title = Path.GetFileNameWithoutExtension(vlcStatus.Information.Category.First().Info .First(i => i.Name == "name").Text); } catch { title = ""; } } if (title != "") { TitleTextView.Text = title; } else { TitleTextView.SetText(Resource.String.app_unknown_title); } if (vlcStatus.State == VlcPlaybackState.Playing) { if (PlayPauseButton.State != MorphButton.MorphState.Start) { PlayPauseButton.SetState(MorphButton.MorphState.Start, true); } } else { if (PlayPauseButton.State != MorphButton.MorphState.End) { PlayPauseButton.SetState(MorphButton.MorphState.End, true); } } }); }