Ejemplo n.º 1
0
            public void Invoke(AsyncResult asyncResultRef)
            {
                var ev = _session.EndGetEvent(asyncResultRef);

                // Trigger an "on Video Ended" event here if needed

                _session.BeginGetEvent(this, null);
            }
Ejemplo n.º 2
0
            public void Invoke(AsyncResult asyncResultRef)
            {
                var ev = _session.EndGetEvent(asyncResultRef);

                if (ev.TypeInfo == MediaEventTypes.EndOfPresentation)
                    OnSongFinishedPlaying(null, null);

                _session.BeginGetEvent(this, null);
            }
Ejemplo n.º 3
0
            public void Invoke(AsyncResult asyncResultRef)
            {
                var ev = _session.EndGetEvent(asyncResultRef);

                // Trigger an "on Video Ended" event here if needed

                if (ev.TypeInfo == MediaEventTypes.SessionTopologyStatus && ev.Get(EventAttributeKeys.TopologyStatus) == TopologyStatus.Ready)
                    _player.OnTopologyReady();

                _session.BeginGetEvent(this, null);
            }
        public void Invoke(MF.AsyncResult asyncResultRef)
        {
            MF.MediaEventTypes eventType;

            try
            {
                using (MF.MediaEvent mediaEvent = m_session.EndGetEvent(asyncResultRef))
                {
                    // Look for existing awaitor action and handle it if there is one
                    lock (m_asyncEventWaitersLock)
                    {
                        for (int loop = 0; loop < m_asyncEventWaiters.Count; loop++)
                        {
                            if (m_asyncEventWaiters[loop](mediaEvent))
                            {
                                m_asyncEventWaiters.RemoveAt(loop);
                                break;
                            }
                        }
                    }

                    // Some generic event handling
                    eventType = mediaEvent.TypeInfo;
                    switch (eventType)
                    {
                    case MF.MediaEventTypes.EndOfPresentation:
                        m_syncContext.Post((arg) =>
                        {
                            if (EndOfPresentation != null)
                            {
                                EndOfPresentation(this, EventArgs.Empty);
                            }
                        }, null);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                // Dispatch exception to UI thread
                m_syncContext.Post((arg) =>
                {
                    throw new SeeingSharpException("Exception curing MediaFoundation session event processing", ex);
                }, null);
            }

            // Reregister for next event
            m_session.BeginGetEvent(this, null);
        }
Ejemplo n.º 5
0
        public override void Invoke(AsyncResult asyncResult)
        {
            // EndGetEvent mandatory
            var evt = session.EndGetEvent(asyncResult);

            var typeInfo = evt.TypeInfo;
            if (typeInfo != MediaEventTypes.SessionClosed)
            {
                // If not closed, continnue to subscribe to next events
                session.BeginGetEvent(this, null);
            }

            // Call the callback
            eventCallback(evt);
        }
Ejemplo n.º 6
0
            public void Invoke(AsyncResult asyncResultRef)
            {
                var ev = _session.EndGetEvent(asyncResultRef);

                switch (ev.TypeInfo)
                {
                    case MediaEventTypes.EndOfPresentation:
                        _sessionState = SessionState.Ended;
                        OnSongFinishedPlaying(null, null);
                        break;
                    case MediaEventTypes.SessionTopologyStatus:
                        if (ev.Get(EventAttributeKeys.TopologyStatus) == TopologyStatus.Ready)
                            OnTopologyReady();
                        break;
                    case MediaEventTypes.SessionStopped:
                        OnSessionStopped();
                        break;
                }

                _session.BeginGetEvent(this, null);
            }
Ejemplo n.º 7
0
 private static int InvokeImpl(IntPtr thisPtr, IntPtr asyncResultPtr)
 {
     AsyncResult asyncResult = null;
     try
     {
         var shadow = ToShadow<AsyncCallbackShadow>(thisPtr);
         var callback = (IAsyncCallback) shadow.Callback;
         asyncResult = new AsyncResult(asyncResultPtr);
         callback.Invoke(asyncResult);
     }
     catch (Exception exception)
     {
         return (int) SharpDX.Result.GetResultFromException(exception);
     }
     finally
     {
         // Clear the NativePointer to make sure that there will be no false indication from ObjectTracker
         if (asyncResult != null)
         {
             asyncResult.NativePointer = IntPtr.Zero;
         }
     }
     return Result.Ok.Code;
 }
Ejemplo n.º 8
0
            public void Invoke(AsyncResult asyncResultRef)
            {
                var ev = _session.EndGetEvent(asyncResultRef);

                // Trigger an "on Video Ended" event here if needed
                if (ev.TypeInfo == MediaEventTypes.SessionTopologyStatus && ev.Get(EventAttributeKeys.TopologyStatus) == TopologyStatus.Ended)
                {
                    Console.WriteLine("Video ended");
                    if (!_player.SetNewVideo) _player.PlatformPlay();
                    else {
                        _player.SetNewVideo = false;
                    }
                }

                if (ev.TypeInfo == MediaEventTypes.SessionTopologyStatus && ev.Get(EventAttributeKeys.TopologyStatus) == TopologyStatus.Ready)
                    _player.OnTopologyReady();

                _session.BeginGetEvent(this, null);
            }