コード例 #1
0
 /// <summary>
 /// Obtient une capture de la vidéo en cours avec des annotations
 /// </summary>
 /// <param name="stream"></param>
 public void GetThumbnailWithAnnotations(Stream stream) => AnnotationsAdornment.GetSaveCommand(KMediaPlayer.MediaElement.VideoImage)?.Execute(stream);
コード例 #2
0
 public void ResetAnnotations() =>
 AnnotationsAdornment.GetClearAnnotationsCommand(KMediaPlayer.MediaElement.VideoImage)?.Execute(null);
コード例 #3
0
        private void OnMediaPlayerActionEvent(MediaPlayerActionEvent e)
        {
            if (e.Sender == AssociatedObject.DataContext || e.Sender == AssociatedObject)
            {
#if DEBUG_QUEUEING
                TraceManager.TraceDebug($"Execute : {e.Id} - {e.Action}");
#endif
                Action action = null;

                switch (e.Action)
                {
                case MediaPlayerAction.Play:
                    action = () => MediaPlayer.Play();
                    break;

                case MediaPlayerAction.Pause:
                    action = () => MediaPlayer.Pause();
                    break;

                case MediaPlayerAction.PlayPause:
                    if (MediaPlayer.IsPlaying)
                    {
                        action = () => MediaPlayer.Pause();
                    }
                    else
                    {
                        action = () => MediaPlayer.Play();
                    }
                    break;

                case MediaPlayerAction.Stop:
                    action = () => MediaPlayer.Stop();
                    break;

                case MediaPlayerAction.Mute:
                    if (KMediaPlayer != null)
                    {
                        action = () => KMediaPlayer.Mute();
                    }
                    break;

                case MediaPlayerAction.Unmute:
                    if (KMediaPlayer != null)
                    {
                        action = () => KMediaPlayer.Unmute();
                    }
                    break;

                case MediaPlayerAction.ToggleMute:
                    if (KMediaPlayer != null)
                    {
                        action = () => KMediaPlayer.ToggleMute();
                    }
                    break;

                case MediaPlayerAction.StepBackward:
                    action = () => MediaPlayer.StepBackward();
                    break;

                case MediaPlayerAction.StepForward:
                    action = () => MediaPlayer.StepForward();
                    break;

                case MediaPlayerAction.ShowTimeline:
                    if (KMediaPlayer != null)
                    {
                        action = () => KMediaPlayer.TimelineShow(e.ShowTimelineStart, e.ShowTimelineEnd, true);
                    }
                    break;

                case MediaPlayerAction.ResetTimeline:
                    if (KMediaPlayer != null)
                    {
                        action = () => KMediaPlayer.TimelineReset();
                    }
                    break;

                case MediaPlayerAction.ActivateMediaPlayerService:
                    action = () => IoC.Resolve <IServiceBus>().Register <IMediaPlayerService>(this);
                    break;

                case MediaPlayerAction.UnactivateMediaPlayerService:
                    action = () => IoC.Resolve <IServiceBus>().Unregister <IMediaPlayerService>();
                    break;

                case MediaPlayerAction.ExecuteWhenDispatcherReady:
                    action = e.ActionWhenPlayerDispatcherReady;
                    break;

                case MediaPlayerAction.ExecuteOnPlayerWhenDispatcherReady:
                    action = () => e.ActionOnPlayerWhenPlayerDispatcherReady(MediaPlayer);
                    break;

                case MediaPlayerAction.ToggleScreenMode:
                    action = () =>
                    {
                        if (KMediaPlayer.ScreenModeCommand != null && KMediaPlayer.ScreenModeCommand.CanExecute(null))
                        {
                            KMediaPlayer.ScreenModeCommand.Execute(null);
                        }
                    };
                    break;

                case MediaPlayerAction.ShowAnnotations:
                    action = () =>
                    {
                        AnnotationsAdornment.SetAnnotationsIsVisible(KMediaPlayer.MediaElement.VideoImage, true);
                        AnnotationsAdornment.SetIsInEditMode(KMediaPlayer.MediaElement.VideoImage, true);
                    };
                    break;

                case MediaPlayerAction.HideAnnotations:
                    action = () =>
                    {
                        if (AnnotationsAdornment.GetIsVisible(KMediaPlayer.MediaElement.VideoImage))
                        {
                            AnnotationsAdornment.DestroyAnnotations(KMediaPlayer.MediaElement.VideoImage);
                        }
                    };
                    break;

                default:
                    break;
                }

                if (action != null)
                {
                    if (e.SendWhenPlayerDispatcherReady)
                    {
                        Action <Action> onDispatcherAction = (a) =>
                        {
                            if (MediaPlayer is KMediaPlayer)
                            {
                                if (KMediaPlayer.MediaElement != null)
                                {
                                    KMediaPlayer.MediaElement.BeginInvokeOnMediaPlayerDispatcher((Action) delegate
                                    {
                                        Dispatcher.Invoke(a);
                                    });
                                }
                                else
                                {
                                    a();
                                }
                            }
                            else if (MediaPlayer is KMiniPlayer)
                            {
                                if (KMiniPlayer.MediaElement != null)
                                {
                                    KMiniPlayer.MediaElement.BeginInvokeOnMediaPlayerDispatcher((Action) delegate
                                    {
                                        Dispatcher.Invoke(a);
                                    });
                                }
                                else
                                {
                                    a();
                                }
                            }
                        };

                        if (MediaPlayer is KMediaPlayer)
                        {
                            if (KMediaPlayer.MediaElement == null)
                            {
                                Dispatcher.BeginInvoke(onDispatcherAction, System.Windows.Threading.DispatcherPriority.Loaded, action);
                            }
                            else
                            {
                                onDispatcherAction(action);
                            }
                        }
                        else if (MediaPlayer is KMiniPlayer)
                        {
                            if (KMiniPlayer.MediaElement == null)
                            {
                                Dispatcher.BeginInvoke(onDispatcherAction, System.Windows.Threading.DispatcherPriority.Loaded, action);
                            }
                            else
                            {
                                onDispatcherAction(action);
                            }
                        }
                    }
                    else
                    {
                        action();
                    }
                }
            }
        }