void element_ManifestReady(object sender, EventArgs e) { foreach (SegmentInfo segment in this.element.ManifestInfo.Segments) { audioTracks = new List <StreamInfo>(); IList <StreamInfo> streamInfoList = segment.AvailableStreams; foreach (StreamInfo stream in streamInfoList) { if (stream.Type == MediaStreamType.Video) { playingStream = stream; tracks = stream.AvailableTracks.ToList <TrackInfo>(); ManifestEventArgs args = new ManifestEventArgs(tracks.ToList <Object>()); BitratesReady(this, args); } else if (stream.Type == MediaStreamType.Audio) { audioTracks.Add(stream); } } ManifestEventArgs audioArgs = new ManifestEventArgs(audioTracks.ToList <Object>()); AudioTracksReady(this, audioArgs); } }
void media_BitratesReady(object sender, ManifestEventArgs e) { List <Object> tracks = e.Flavors; String bitrates = ""; if (tracks != null) { for (int i = 0; i < tracks.Count; i++) { bitrates += "{\"type\":\"video/ism\",\"assetid\":" + "\"ism_" + i + "\"" + ",\"bandwidth\":" + ((TrackInfo)tracks.ElementAt(i)).Bitrate + ",\"height\":0}"; if (i < tracks.Count - 1) { bitrates += ","; } } } bitrates = "{\"flavors\":[" + bitrates + "]}"; SendEvent("flavorsListChanged", bitrates); }
void media_AudioTracksReady(object sender, ManifestEventArgs e) { List <Object> tracks = e.Flavors; String languages = ""; if (tracks != null) { string langName = ""; for (int i = 0; i < tracks.Count; i++) { ((StreamInfo)tracks.ElementAt(i)).Attributes.TryGetValue("Name", out langName); languages += "{\"name\":\"" + langName + "\",\"index\":" + i + "}"; if (i < tracks.Count - 1) { languages += ","; } } } languages = "{\"languages\":[" + languages + "]}"; SendEvent("audioTracksReceived", languages); //notify default audio index SendEvent("audioTrackSelected", "{\"index\":" + (media as SmoothStreamingElement).getCurrentAudioIndex() + "}"); }
void media_BitratesReady(object sender, ManifestEventArgs e) { List<Object> tracks = e.Flavors; String bitrates = ""; if (tracks != null) { for (int i = 0; i < tracks.Count; i++) { bitrates += "{\"type\":\"video/ism\",\"assetid\":" + "\"ism_" + i + "\""+ ",\"bandwidth\":" + ((TrackInfo) tracks.ElementAt(i)).Bitrate + ",\"height\":0}"; if (i < tracks.Count - 1) { bitrates += ","; } } } bitrates = "{\"flavors\":[" + bitrates + "]}"; SendEvent("flavorsListChanged", bitrates); }
void media_AudioTracksReady(object sender, ManifestEventArgs e) { List<Object> tracks = e.Flavors; String languages = ""; if (tracks != null) { string langName = ""; for (int i = 0; i < tracks.Count; i++) { ((StreamInfo)tracks.ElementAt(i)).Attributes.TryGetValue("Name", out langName); languages += "{\"name\":\"" + langName + "\",\"index\":" + i + "}"; if (i < tracks.Count - 1) { languages += ","; } } } languages = "{\"languages\":[" + languages + "]}"; SendEvent("audioTracksReceived", languages); //notify default audio index SendEvent("audioTrackSelected", "{\"index\":" + (media as SmoothStreamingElement).getCurrentAudioIndex() + "}"); }
void element_MediaOpened(object sender, RoutedEventArgs e) { if (this.element.IsLive) { this.element.StartSeekToLive(); } foreach (SegmentInfo segment in this.element.ManifestInfo.Segments) { audioTracks = new List<StreamInfo>(); textTracks = new List<StreamInfo>(); IList<StreamInfo> streamInfoList = segment.AvailableStreams; List<StreamInfo> selectStreams = segment.SelectedStreams.ToList<StreamInfo>(); foreach (StreamInfo stream in streamInfoList) { if (stream.Type == MediaStreamType.Video) { playingStream = stream; tracks = stream.AvailableTracks.ToList<TrackInfo>(); ManifestEventArgs args = new ManifestEventArgs(tracks.ToList<Object>()); BitratesReady(this, args); } else if (stream.Type == MediaStreamType.Audio) { audioTracks.Add(stream); } //subtitles else if (stream.Type == MediaStreamType.Script && stream.Subtype == "CAPT") { textTracks.Add(stream); } } if (MediaOpened != null) { MediaOpened(sender, e); } ManifestEventArgs audioArgs = new ManifestEventArgs(audioTracks.ToList<Object>()); AudioTracksReady(this, audioArgs); ManifestEventArgs textArgs = new ManifestEventArgs(textTracks.ToList<Object>()); TextTracksReady(this, textArgs); } }
void element_ManifestReady(object sender, EventArgs e) { foreach (SegmentInfo segment in this.element.ManifestInfo.Segments) { audioTracks = new List<StreamInfo>(); IList<StreamInfo> streamInfoList = segment.AvailableStreams; foreach (StreamInfo stream in streamInfoList) { if (stream.Type == MediaStreamType.Video) { playingStream = stream; tracks = stream.AvailableTracks.ToList<TrackInfo>(); ManifestEventArgs args = new ManifestEventArgs( tracks.ToList<Object>() ); BitratesReady(this, args); } else if (stream.Type == MediaStreamType.Audio) { audioTracks.Add(stream); } } ManifestEventArgs audioArgs = new ManifestEventArgs(audioTracks.ToList<Object>()); AudioTracksReady(this, audioArgs); } }
/** * parse given args to languages string * */ private string parseLanguages(ManifestEventArgs e) { List<Object> tracks = e.Flavors; String languages = ""; if (tracks != null) { string name = ""; string langName = ""; for (int i = 0; i < tracks.Count; i++) { ((StreamInfo)tracks.ElementAt(i)).Attributes.TryGetValue("Name", out name); ((StreamInfo)tracks.ElementAt(i)).Attributes.TryGetValue("Language", out langName); languages += "{\"label\":\"" + name + "\",\"index\":" + i + ",\"language\":\"" + langName + "\"}"; if (i < tracks.Count - 1) { languages += ","; } } } languages = "{\"languages\":[" + languages + "]}"; return languages; }
void media_TextTracksReady(object sender, ManifestEventArgs e) { SendEvent("textTracksReceived", parseLanguages(e)); }
void media_BitratesReady(object sender, ManifestEventArgs e) { List<TrackInfo> tracks = e.Flavors.Cast<TrackInfo>().ToList(); String bitrates = ""; if (tracks != null) { foreach (TrackInfo ti in tracks) { int height = 0; if (ti.Attributes.ContainsKey("MaxHeight")) { Int32.TryParse(ti.Attributes["MaxHeight"], out height); } int width = 0; if (ti.Attributes.ContainsKey("MaxWidth")) { Int32.TryParse(ti.Attributes["MaxWidth"], out width); } bitrates += "{\"type\":\"video/ism\",\"assetid\":" + "\"ism_" + ti.Index + "\"" + ",\"bandwidth\":" + ti.Bitrate + ",\"height\":" + height + ",\"width\":" + width + "}"; if (tracks.IndexOf(ti) < tracks.Count - 1) { bitrates += ","; } } } bitrates = "{\"flavors\":[" + bitrates + "]}"; SendEvent("flavorsListChanged", bitrates); }
void media_AudioTracksReady(object sender, ManifestEventArgs e) { SendEvent("audioTracksReceived", parseLanguages(e)); //notify default audio index SendEvent("audioTrackSelected", "{\"index\":" + (media as SmoothStreamingElement).getCurrentAudioIndex() + "}"); }