Exemple #1
0
 public void Close()
 {
     Stop();
     try {
         _audioVolume?.Dispose();
         _videoControl?.Dispose();
         _mediaSession?.Close();
     } catch (SharpDXException) { }
     _audioVolume  = null;
     _videoControl = null;
 }
Exemple #2
0
        // return every timer click - set by timer control on aspx page to be every 1000ms
        protected void Page_PreRender(object sender, EventArgs e)
        {
            try
            {
                // Look at blob container that contains the videos
                // generated by the worker role. Perform a query
                // of the its contents and return the list of all of the
                // blobs whose name begins with the string "videos".
                // It returns an enumerator of their URLs.
                // Place that enumerator into list view as its data source.
                VideoDisplayControl.DataSource = from o in getVideoPlaylistContainer().GetDirectoryReference("samples").ListBlobs()
                                                 select new { Url = o.Uri, Title = getTitle(o.Uri) };

                // Tell the list view to bind to its data source, thereby
                // showing
                VideoDisplayControl.DataBind();
            }
            catch (Exception)
            {
            }
        }
Exemple #3
0
        private void OnMediaEvent(MediaEvent ev)
        {
            Trace.WriteLine($"HwndRenderSession::OnMediaEvent(): {ev.TypeInfo} {ev.Status}");

            switch (ev.TypeInfo)
            {
            case MediaEventTypes.SessionClosed:
                // cleanup
                AfterClose();
                _isSessionReady.OnNext(false);
                break;

            case MediaEventTypes.SessionTopologyStatus:
                if (ev.Status.Failure)
                {
                    _playFailed.OnNext(ev.Status.Code);
                    return;
                }
                Trace.WriteLine($"HwndRenderSession::OnMediaEvent(): => TopologyStatus={ev.Get(EventAttributeKeys.TopologyStatus)}");
                if (ev.Status.Success && ev.Get(EventAttributeKeys.TopologyStatus) == TopologyStatus.Ready)
                {
                    using (var sp = _mediaSession.QueryInterface <ServiceProvider>()) {
                        _videoControl = sp.GetService <VideoDisplayControl>(CustomServiceKeys.VideoRender);
                        _audioVolume  = sp.GetService <SimpleAudioVolume>(MediaServiceKeys.PolicyVolume);
                    }
                    _isSessionReady.OnNext(true);
                }
                break;

            //case MediaEventTypes.SessionStarted:
            //case MediaEventTypes.EndOfPresentation:
            //case MediaEventTypes.SessionStopped:
            default:
                break;
            }
        }
Exemple #4
0
 void mediaSession_OnSessionTopologyStatus(MediaEvent mediaEvent)
 {
     if (mediaEvent.EventTopologyStatus == MFTopoStatus.Ready)
     {
         videoDisplayControl = VideoDisplayControl.Create(mediaSession);
         mediaSession.Start();
     }
 }