コード例 #1
0
ファイル: LiveSourceBufferManager.cs プロジェクト: ice0/test
        private async Task <bool> ReloadManifest()
        {
            try
            {
                //Redownload manifest to pick up where it left off
                var mpdUrl = manifest.SourceUrl;
                manifest = new Manifest(mpdUrl);
                var document = await manifest.LoadManifestAsync(mpdUrl);

                DashManifestParser mpdParser = new DashManifestParser(document, ref manifest);

                return(mpdParser.Parse());
            }
            catch (Exception e)
            {
#if DEBUG
                Logger.Log("Error reloading manifest in the Live Source Buffer: " + e.Message);
#endif
                return(false);
            }
        }
コード例 #2
0
        private async Task ReloadManifest()
        {
            try
            {
                var sourceUrl = manifest.SourceUrl;
                manifest = new Manifest(sourceUrl);
                var document = await manifest.LoadManifestAsync(sourceUrl);

                DashManifestParser mpdParser = new DashManifestParser(document, ref manifest);
                if (!mpdParser.Parse())
                {
#if DEBUG
                    Logger.Log("The Parser failed to parse this mpd");
#endif
                    return;
                }
            }
            catch (Exception e)
            {
#if DEBUG
                Logger.Log("Error occured reloading manifest: " + e.Message);
#endif
            }
        }
コード例 #3
0
ファイル: LiveDashPlayer.cs プロジェクト: ice0/test
        /// <summary>
        /// Downloads the manifest from the given source, parses the manifest
        /// and sets the source on the media element 
        /// </summary>
        /// <param name="source">The URL of the source MPD</param>
        /// <param name="mediaElement">The MediaElement to start playback</param>
        /// <returns></returns>
        public async Task Initialize(Uri source, MediaElement mediaElement)
        {
            //1) Download manifest
            var sourceUrlText = source.AbsoluteUri;
            try
            {
                var manifest = new Manifest(sourceUrlText);
                var document = await manifest.LoadManifestAsync(sourceUrlText);

                //2) Parse manifest
                DashManifestParser mpdParser = new DashManifestParser(document, ref manifest);
                if (mpdParser.Parse())
                {

                    if (!manifest.IsSupportedProfile)
                    {
#if DEBUG
                        Logger.Log("The profiles attribute does not contain the \"urn:mpeg:dash:profile:isoff-live:2011\" profile, so it may not work as expected.");
#endif
                    }
                    if (manifest.IsLive)
                    {
                        //3) Play using MSE if it is live
                        MseStreamSource mseSource = new MseStreamSource();
                        player = new Player(mediaElement, mseSource, manifest);
                        if (haveSetLiveOffset && manifest.IsLive)
                        {
                            player.HasLiveOffsetValue = true;
                            player.LiveOffset = liveOffset;
                        }
                        player.Initialize();
                    }
                    else
                    {
                        // Otherwise, use our Adaptive Media Source for on demand content
                        var result = await AdaptiveMediaSource.CreateFromUriAsync(source);
                        if (result.Status != AdaptiveMediaSourceCreationStatus.Success)
                        {
                            throw new Exception("Unable to create media source because: " + result.Status);
                        }
                        var adaptiveSource = result.MediaSource;

                        mediaElement.SetMediaStreamSource(adaptiveSource);
                        mediaElement.Play();
                    }


                }

                else
                {
#if DEBUG
                    Logger.Log("The Parser failed to parse this mpd");
#endif
                    return;
                }
            }
            catch (Exception e)
            {
#if DEBUG
                Logger.Log("Exception when initializing player: " + e.Message + " " + Logger.Display(e));
#endif
            }
        }