/** * PinPPageを開く * @param source 動画ソース * @param position 動画を再生する位置(-1なら停止した状態で開く) * @param reqSize プレーヤーのサイズ(参考値・・・この通りになるとは限らない)/ nullなら、サイズは成り行き任せ * @param opened IPinPPlayerを返すデリゲート (通知不要ならnull) */ public static async Task <bool> OpenPinP(MediaSource source, double position = -1, Size?reqSize = null, NotifyPinPOpened opened = null, object clientData = null) { if (null == source) { return(false); } var info = new PinPCreationInfo(source, position, reqSize, clientData); if (null != opened) { if (null == sNotifyHanders) { sNotifyHanders = new Dictionary <int, NotifyPinPOpened>(); } sNotifyHanders.Add(info.ID, opened); } CoreApplicationView newView = CoreApplication.CreateNewView(); int newViewId = 0; await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { Frame frame = new Frame(); frame.Navigate(typeof(WvvPinPPage), info); Window.Current.Content = frame; Window.Current.Activate(); newViewId = ApplicationView.GetForCurrentView().Id; var option = getCompactOverlayOption(reqSize); await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, option); }); return(await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId)); }
/** * コンストラクタ * * 意味的には private だが、Frame#Navigate()で開くために、publicでなければならない。 */ public WvvPinPPage() { mInfo = null; Loaded += OnLoaded; // xaml に定義するとメモリリークする // Unloadedイベントは来ないので定義しない。代わりに、SystemNavigationManagerPreview.CloseRequested を使う。 this.InitializeComponent(); }
//private void OnUnloaded(object sender, RoutedEventArgs e) //{ // Debug.WriteLine("MediaPage Unloaded."); // Dispose(); //} /** * リソース解放 */ private void Dispose() { var player = mPlayer.MediaPlayer; if (null != player) { mPlayer.UnregisterPropertyChangedCallback(MediaPlayerElement.IsFullWindowProperty, mFullWindowListenerToken); mPlayer.SetMediaPlayer(null); player.Dispose(); //この方法は、Restricted Capabilities の指定が必要なので、できれば避けたい。 //SystemNavigationManagerPreview.GetForCurrentView().CloseRequested -= OnCloseRequested; } Closed = null; mInfo = null; CmLog.debug("WvvPinPPage.Dispose: PinP Player Disposed.)"); }
/** * このページに遷移してきた・・・まだViewはロードされていない。 */ protected override void OnNavigatedTo(NavigationEventArgs e) { mInfo = e.Parameter as PinPCreationInfo; }