public override void Disconnect() { if (GSMTCSession != null) { GSMTCSession.MediaPropertiesChanged -= GSMTCSession_MediaPropertiesChanged; GSMTCSession.PlaybackInfoChanged -= GSMTCSession_PlaybackInfoChanged; GSMTCSession.TimelinePropertiesChanged -= GSMTCSession_TimelinePropertiesChanged; } GSMTCSession = null; sourceAppInfo.Dispose(); sourceAppInfo = null; }
private void Initialize() { sourceAppInfo = SourceAppInfo.FromAppId(GSMTCSession.SourceAppUserModelId); if (sourceAppInfo != null) { sourceAppInfo.InfoFetched += SourceAppInfo_InfoFetched; } ActivateMediaSourceCommand = new RelayCommand(sourceAppInfo.Activate, () => sourceAppInfo != null); GSMTCSession.MediaPropertiesChanged += GSMTCSession_MediaPropertiesChanged; GSMTCSession.PlaybackInfoChanged += GSMTCSession_PlaybackInfoChanged; GSMTCSession.TimelinePropertiesChanged += GSMTCSession_TimelinePropertiesChanged; UpdateSessionInfo(GSMTCSession); }
public override void Disconnect() { if (mediaPlaybackDataSource != null) { try { mediaPlaybackDataSource.MediaPlaybackDataChanged -= MediaPlaybackDataSource_MediaPlaybackDataChanged; } catch { } } mediaPlaybackDataSource = null; NPSession = null; sourceAppInfo.Dispose(); sourceAppInfo = null; }
private void Initialize() { if (NPSession == null) { throw new NullReferenceException(nameof(NPSession)); } try { sourceAppId = NPSession.SourceAppId; } catch { } sourceAppInfo = SourceAppInfo.FromData(new SourceAppInfoData() { AppUserModelId = sourceAppId, ProcessId = NPSession.PID, MainWindowHandle = NPSession.Hwnd, DataType = SourceAppInfoDataType.FromProcessId }); if (sourceAppInfo != null) { sourceAppInfo.InfoFetched += SourceAppInfo_InfoFetched; sourceAppInfo.FetchInfosAsync(); ActivateMediaSourceCommand = new RelayCommand(sourceAppInfo.Activate, () => sourceAppInfo != null); } mediaPlaybackDataSource = NPSession.ActivateMediaPlaybackDataSource(); if (mediaPlaybackDataSource == null) { throw new InvalidOperationException(nameof(mediaPlaybackDataSource) + " should not be null"); } mediaPlaybackDataSource.MediaPlaybackDataChanged += MediaPlaybackDataSource_MediaPlaybackDataChanged; UpdateSessionInfo(); }