public LiveDetailPage() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Disabled; dispRequest = new DisplayRequest(); DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += DataTransferManager_DataRequested; _config = new FFmpegInteropConfig(); _config.FFmpegOptions.Add("rtsp_transport", "tcp"); _config.FFmpegOptions.Add("user_agent", "Mozilla/5.0 BiliDroid/1.12.0 ([email protected])"); _config.FFmpegOptions.Add("referer", "https://live.bilibili.com/"); //每过2秒就设置焦点 timer_focus = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(2) }; timer_focus.Tick += Timer_focus_Tick; controlTimer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) }; controlTimer.Tick += ControlTimer_Tick; settingVM = new SettingVM(); liveRoomVM = new LiveRoomVM(); mediaPlayer = new MediaPlayer(); mediaPlayer.PlaybackSession.PlaybackStateChanged += PlaybackSession_PlaybackStateChanged; mediaPlayer.PlaybackSession.BufferingStarted += PlaybackSession_BufferingStarted; mediaPlayer.PlaybackSession.BufferingProgressChanged += PlaybackSession_BufferingProgressChanged; mediaPlayer.PlaybackSession.BufferingEnded += PlaybackSession_BufferingEnded; mediaPlayer.MediaOpened += MediaPlayer_MediaOpened; mediaPlayer.MediaEnded += MediaPlayer_MediaEnded;; mediaPlayer.MediaFailed += MediaPlayer_MediaFailed; liveRoomVM.ChangedPlayUrl += LiveRoomVM_ChangedPlayUrl; liveRoomVM.AddNewDanmu += LiveRoomVM_AddNewDanmu; liveRoomVM.LotteryEnd += LiveRoomVM_LotteryEnd; this.Loaded += LiveDetailPage_Loaded; this.Unloaded += LiveDetailPage_Unloaded; //TODO 快捷键 }
private void StopPlay() { if (mediaPlayer != null) { mediaPlayer.Pause(); mediaPlayer.Source = null; } if (interopMSS != null) { interopMSS.Dispose(); interopMSS = null; } liveRoomVM.Dispose(); //取消屏幕常亮 if (dispRequest != null) { dispRequest = null; } liveRoomVM = null; SetFullScreen(false); MiniWidnows(false); }