コード例 #1
0
        /// <summary>
        /// Parse a m3u8 playlist into a dictionary with streamname and streamurl
        /// Sorting and streamname are customizable
        /// </summary>
        /// <param name="playlist">the m3u8 data</param>
        /// <param name="url">url to use if the m3u8 data contains relative urls</param>
        /// <param name="comparer">comparing two HlsStreamInfo, used in the sorting</param>
        /// <param name="formatter">formating display string for a given HlsStreamInfo</param>
        /// <returns>Dictionary with the streamnames and urls</returns>
        public static Dictionary <string, string> GetPlaybackOptions(string playlist, string url, HlsStreamInfoComparer comparer, HlsStreamInfoFormatter formatter)
        {
            Dictionary <string, string> playbackOptions = new Dictionary <string, string>();
            var tmp = new HlsPlaylistParser(playlist, url);

            foreach (var streamInfo in tmp.StreamInfos.OrderBy(info => info, comparer))
            {
                var streamName = formatter.Format(streamInfo);
                if (!playbackOptions.ContainsKey(streamName))
                {
                    playbackOptions.Add(streamName, streamInfo.Url);
                }
            }
            return(playbackOptions);
        }
コード例 #2
0
 static HlsStreamInfoComparer()
 {
     BandwidthHighLow = new BandwidthComparer(false);
     BandwidtLowHigh  = new BandwidthComparer(true);
 }