protected override void DefWndProc(ref Message m) { if (m.Msg == MsgHelper.WM_COPYDATA) { MsgHelper.COPYDATASTRUCT cdata = new MsgHelper.COPYDATASTRUCT(); cdata = (MsgHelper.COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, cdata.GetType()); string dt = cdata.lpData; if (dt.Contains("ok")) { pHandle = int.Parse(TextHelper.XtoYGetTo(dt, "ok[", "]", 0)); } else if (dt.Contains("Ps[")) { Ps = double.Parse(TextHelper.XtoYGetTo(dt, "Ps[", "]", 0)); } else if (dt.Contains("PsAll[")) { PsAll = double.Parse(TextHelper.XtoYGetTo(dt, "PsAll[", "]", 0)); } else if (dt == "MediaEnded") { MediaEnded.Invoke(); } else if (dt == "ToAway") { ToAway.Invoke(); } } else { base.DefWndProc(ref m); } }
void OnMediaEnded(int handle, int channel, int data, IntPtr User) { if (MediaEnded != null && !Loop) { MediaEnded.Invoke(this, new EventArgs()); } }
internal void PostMediaEndedEvent() { LogEventStart(nameof(MediaEnded)); Library.GuiContext.EnqueueInvoke(() => { MediaEnded?.Invoke(this, EventArgs.Empty); LogEventDone(nameof(MediaEnded)); }); }
private void OnMediaEnded(object sender, NSNotificationEventArgs args) { MediaEnded?.Invoke(this, null); if (Source is MediaPlaybackList && (AVPlayerItem)args.Notification.Object != _player.Items.Last()) { return; } PlaybackSession.PlaybackState = MediaPlaybackState.None; }
private void DoTick() { tickTimer.Stop(); Position = GetPosition(Position); if (NaturalDuration.HasTimeSpan && Position >= NaturalDuration.TimeSpan) { MediaEnded?.Invoke(this, new RoutedEventArgs()); } SetTickTimer(); }
public void OnCompletion(AndroidMediaPlayer mp) { MediaEnded?.Invoke(this, null); PlaybackSession.PlaybackState = MediaPlaybackState.None; // Play next item in playlist, if any if (_playlistItems != null && _playlistIndex < _playlistItems.Count - 1) { _player.Reset(); SetVideoSource(_playlistItems[++_playlistIndex]); _player.Prepare(); _player.Start(); } }
protected override void OnApplyTemplate() { MediaElement = (MediaElement)GetTemplateChild("MainMediaElement"); if (MediaElement != null) { MediaElement.CurrentStateChanged += (s, e) => CurrentStateChanged?.Invoke(this, e); MediaElement.MediaEnded += (s, e) => MediaEnded?.Invoke(this, e); MediaElement.MediaOpened += (s, e) => MediaOpened?.Invoke(this, e); MediaElement.MediaFailed += (s, e) => MediaFailed?.Invoke(this, e); MediaElement.SeekCompleted += (s, e) => SeekCompleted?.Invoke(this, e); MediaElement.VolumeChanged += (s, e) => VolumeChanged?.Invoke(this, e); } base.OnApplyTemplate(); }
private void MediaPlayer_Ended(object sender, RoutedEventArgs args) { if (MediaEnded != null) { MediaEnded.Invoke(sender, args); } if (Repeat) { if (_Phase == Phase.Opened) { _MediaElement.Position = TimeSpan.Zero; } } }
/// <summary> /// Play the specified audio /// </summary> /// <param name="audio">The audio</param> public void PlayAudio(Stream audio) { if (mediaPlayer != null) { StopAudio(); } mediaPlayer = new MediaPlayer(); /// <see cref="MediaEnded"/> event handler raises when media playing is ended. mediaPlayer.MediaEnded += (sender, args) => MediaEnded?.Invoke(sender, System.EventArgs.Empty); try { mediaPlayer.Source = MediaSource.CreateFromStream(audio.AsRandomAccessStream(), ".wav"); } catch { throw new ArgumentException("The audio file is not in the correct format."); } mediaPlayer.Play(); }
private void CheckTarget() { if (Position < target) { return; } if (Mode == PlayTypeState.Highlights && Position >= GetLastTarget()) { MediaEnded?.Invoke(this, Source); } else { UpdatePosition(); } }
public Media() { InitializeComponent(); //bug? This is required(atleast on my pc) because DirectSound seems to be failing for some reason //https://github.com/unosquare/ffmediaelement/issues/319 MediaPlayer.RendererOptions.UseLegacyAudioOut = true; MediaPlayer.MediaEnded += (s, e) => MediaEnded?.Invoke(s, e); _defaultCursor = this.Cursor; _inactivityTimer = new DispatcherTimer(); _inactivityTimer.Interval = TimeSpan.FromSeconds(4); _inactivityTimer.Tick += OnInactivity; _inactivityTimer.Start(); Application.Current.MainWindow.PreviewMouseMove += OnActivity; }
private Result ChannelEndCallback(IntPtr channelraw, ChannelControlType controltype, ChannelControlCallbackType type, IntPtr commanddata1, IntPtr commanddata2) { if (type == ChannelControlCallbackType.Syncpoint) { _fmodSound?.GetSyncPointInfo(_last15SyncPoint, new StringBuilder("songabouttoend"), 0, out _last15Offset, TimeUnit.Ms); uint last5Offset = 0; _fmodSound?.GetSyncPointInfo(_last5SyncPoint, new StringBuilder("fade"), 0, out last5Offset, TimeUnit.Ms); if (_position >= _fmodSound?.LengthInMilliseconds) { MediaEnded?.Invoke(this, new MediaEndedEventArgs(PlayerState.Ended)); } else if (_position >= last5Offset) { _fmodChannel.SetFadePoint(_fmodChannel.Volume, 0f, _fmodChannel.GetTotalSamplesLeft(_fmodSound)); } else if (_position >= _last15Offset && _position < last5Offset) { MediaAboutToEnd?.Invoke(this, new MediaAboutToEndEventArgs(CurrentlyPlayingFile)); } } return(Result.Ok); }
private void OnMediaEnded() { MediaEnded?.Invoke(this, null); PlaybackSession.PlaybackState = MediaPlaybackState.None; }
public void OnCompletion(AndroidMediaPlayer mp) { MediaEnded?.Invoke(this, null); }
private void MediaPlayer_MediaEnded(MediaPlayer sender, object args) { MediaEnded?.Invoke(this, args); }
private void HandleMediaEnded(object sender, RoutedEventArgs e) { MediaEnded?.Invoke(sender, e); }
public void OnCompletion(AndroidMediaPlayer mp) { MediaEnded?.Invoke(this, null); PlaybackSession.PlaybackState = MediaPlaybackState.None; }
private void HandleMediaEnded(object?sender, RoutedEventArgs?e) { MediaEnded?.Invoke(sender, new OnlyMMediaEndedEventArgs()); }
protected virtual void OnMediaEnded() { IsActive = false; MediaEnded?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Update message handler /// </summary> /// <param name="eventType">Value of "event-type" in the JSON body</param> /// <param name="body">full JSON message body</param> protected void ProcessEventType(string eventType, JObject body) { StreamStatus status; switch (eventType) { case "SwitchScenes": SceneChanged?.Invoke(this, (string)body["scene-name"]); break; case "ScenesChanged": SceneListChanged?.Invoke(this, EventArgs.Empty); break; case "SourceOrderChanged": SourceOrderChanged?.Invoke(this, (string)body["scene-name"]); break; case "SceneItemAdded": SceneItemAdded?.Invoke(this, (string)body["scene-name"], (string)body["item-name"]); break; case "SceneItemRemoved": SceneItemRemoved?.Invoke(this, (string)body["scene-name"], (string)body["item-name"]); break; case "SceneItemVisibilityChanged": SceneItemVisibilityChanged?.Invoke(this, (string)body["scene-name"], (string)body["item-name"], (bool)body["item-visible"]); break; case "SceneItemLockChanged": SceneItemLockChanged?.Invoke(this, (string)body["scene-name"], (string)body["item-name"], (int)body["item-id"], (bool)body["item-locked"]); break; case "SceneCollectionChanged": SceneCollectionChanged?.Invoke(this, EventArgs.Empty); break; case "SceneCollectionListChanged": SceneCollectionListChanged?.Invoke(this, EventArgs.Empty); break; case "SwitchTransition": TransitionChanged?.Invoke(this, (string)body["transition-name"]); break; case "TransitionDurationChanged": TransitionDurationChanged?.Invoke(this, (int)body["new-duration"]); break; case "TransitionListChanged": TransitionListChanged?.Invoke(this, EventArgs.Empty); break; case "TransitionBegin": TransitionBegin?.Invoke(this, (string)body["name"], (string)body["type"], (int)body["duration"], (string)body["from-scene"], (string)body["to-scene"]); break; case "TransitionEnd": TransitionEnd?.Invoke(this, (string)body["name"], (string)body["type"], (int)body["duration"], (string)body["to-scene"]); break; case "TransitionVideoEnd": TransitionVideoEnd?.Invoke(this, (string)body["name"], (string)body["type"], (int)body["duration"], (string)body["from-scene"], (string)body["to-scene"]); break; case "ProfileChanged": ProfileChanged?.Invoke(this, EventArgs.Empty); break; case "ProfileListChanged": ProfileListChanged?.Invoke(this, EventArgs.Empty); break; case "StreamStarting": StreamingStateChanged?.Invoke(this, OutputState.Starting); break; case "StreamStarted": StreamingStateChanged?.Invoke(this, OutputState.Started); break; case "StreamStopping": StreamingStateChanged?.Invoke(this, OutputState.Stopping); break; case "StreamStopped": StreamingStateChanged?.Invoke(this, OutputState.Stopped); break; case "RecordingStarting": RecordingStateChanged?.Invoke(this, OutputState.Starting); break; case "RecordingStarted": RecordingStateChanged?.Invoke(this, OutputState.Started); break; case "RecordingStopping": RecordingStateChanged?.Invoke(this, OutputState.Stopping); break; case "RecordingStopped": RecordingStateChanged?.Invoke(this, OutputState.Stopped); break; case "RecordingPaused": RecordingPaused?.Invoke(this, EventArgs.Empty); break; case "RecordingResumed": RecordingResumed?.Invoke(this, EventArgs.Empty); break; case "StreamStatus": if (StreamStatus != null) { status = new StreamStatus(body); StreamStatus(this, status); } break; case "PreviewSceneChanged": PreviewSceneChanged?.Invoke(this, (string)body["scene-name"]); break; case "StudioModeSwitched": StudioModeSwitched?.Invoke(this, (bool)body["new-state"]); break; case "ReplayStarting": ReplayBufferStateChanged?.Invoke(this, OutputState.Starting); break; case "ReplayStarted": ReplayBufferStateChanged?.Invoke(this, OutputState.Started); break; case "ReplayStopping": ReplayBufferStateChanged?.Invoke(this, OutputState.Stopping); break; case "ReplayStopped": ReplayBufferStateChanged?.Invoke(this, OutputState.Stopped); break; case "Exiting": OBSExit?.Invoke(this, EventArgs.Empty); break; case "Heartbeat": Heartbeat?.Invoke(this, new Heartbeat(body)); break; case "SceneItemDeselected": SceneItemDeselected?.Invoke(this, (string)body["scene-name"], (string)body["item-name"], (string)body["item-id"]); break; case "SceneItemSelected": SceneItemSelected?.Invoke(this, (string)body["scene-name"], (string)body["item-name"], (string)body["item-id"]); break; case "SceneItemTransformChanged": SceneItemTransformChanged?.Invoke(this, new SceneItemTransformInfo(body)); break; case "SourceAudioMixersChanged": SourceAudioMixersChanged?.Invoke(this, new AudioMixersChangedInfo(body)); break; case "SourceAudioSyncOffsetChanged": SourceAudioSyncOffsetChanged?.Invoke(this, (string)body["sourceName"], (int)body["syncOffset"]); break; case "SourceCreated": SourceCreated?.Invoke(this, new SourceSettings(body)); break; case "SourceDestroyed": SourceDestroyed?.Invoke(this, (string)body["sourceName"], (string)body["sourceType"], (string)body["sourceKind"]); break; case "SourceRenamed": SourceRenamed?.Invoke(this, (string)body["newName"], (string)body["previousName"]); break; case "SourceMuteStateChanged": SourceMuteStateChanged?.Invoke(this, (string)body["sourceName"], (bool)body["muted"]); break; case "SourceAudioDeactivated": SourceAudioDeactivated?.Invoke(this, (string)body["sourceName"]); break; case "SourceAudioActivated": SourceAudioActivated?.Invoke(this, (string)body["sourceName"]); break; case "SourceVolumeChanged": SourceVolumeChanged?.Invoke(this, new SourceVolume(body)); break; case "SourceFilterAdded": SourceFilterAdded?.Invoke(this, (string)body["sourceName"], (string)body["filterName"], (string)body["filterType"], (JObject)body["filterSettings"]); break; case "SourceFilterRemoved": SourceFilterRemoved?.Invoke(this, (string)body["sourceName"], (string)body["filterName"]); break; case "SourceFiltersReordered": if (SourceFiltersReordered != null) { List <FilterReorderItem> filters = new List <FilterReorderItem>(); JsonConvert.PopulateObject(body["filters"].ToString(), filters); SourceFiltersReordered?.Invoke(this, (string)body["sourceName"], filters); } break; case "SourceFilterVisibilityChanged": SourceFilterVisibilityChanged?.Invoke(this, (string)body["sourceName"], (string)body["filterName"], (bool)body["filterEnabled"]); break; case "BroadcastCustomMessage": BroadcastCustomMessageReceived?.Invoke(this, (string)body["realm"], (JObject)body["data"]); break; case "MediaEnded": MediaEnded?.Invoke(this, (string)body["sourceName"], (string)body["sourceKind"]); break; case "MediaStarted": MediaStarted?.Invoke(this, (string)body["sourceName"], (string)body["sourceKind"]); break; case "MediaPrevious": MediaPrevious?.Invoke(this, (string)body["sourceName"], (string)body["sourceKind"]); break; case "MediaNext": MediaNext?.Invoke(this, (string)body["sourceName"], (string)body["sourceKind"]); break; case "MediaStopped": MediaStopped?.Invoke(this, (string)body["sourceName"], (string)body["sourceKind"]); break; case "MediaRestarted": MediaRestarted?.Invoke(this, (string)body["sourceName"], (string)body["sourceKind"]); break; case "MediaPaused": MediaPaused?.Invoke(this, (string)body["sourceName"], (string)body["sourceKind"]); break; case "MediaPlaying": MediaPlaying?.Invoke(this, (string)body["sourceName"], (string)body["sourceKind"]); break; case "VirtualCamStarted": VirtualCameraStarted?.Invoke(this, EventArgs.Empty); break; case "VirtualCamStopped": VirtualCameraStopped?.Invoke(this, EventArgs.Empty); break; default: var message = $"Unsupported Event: {eventType}\n{body}"; Console.WriteLine(message); Debug.WriteLine(message); break; } }
protected virtual void OnMediaEnded() { MediaEnded?.Invoke(this, EventArgs.Empty); }
private void Timeline_Completed(object sender, EventArgs e) { MediaEnded?.Invoke(this, Source); }
protected void RaiseMediaEnded() { MediaEnded?.Invoke(); }