示例#1
0
        private void ItemTile_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            VideoPlayPage.PageParams param = new VideoPlayPage.PageParams();
            param.VideoId = Data.VideoId;

            App.Instance.Frame.Navigate(typeof(VideoPlayPage), param);
        }
        public static void HandleCommands(VoiceCommandActivatedEventArgs argus)
        {
            SpeechRecognitionResult speechRecognitionResult = argus.Result;

            string voiceCommandName = speechRecognitionResult.RulePath[0];
            Type NavigationPageType = null;
            VoiceCommand voiceCommand = new VoiceCommand();

            switch (voiceCommandName.ToLower())
            {
                case "closeapp":
                    Application.Current.Exit();
                    break;
                case "openapp":
                    if(App.Instance.Frame.Content == null)
                    {
                        NavigationPageType = typeof(MainPage);
                        App.Instance.Frame.Navigate(NavigationPageType, voiceCommand);
                    }
                    Window.Current.Activate();
                    break;
                case "continuevideo":

                    var settings = ApplicationData.Current.LocalSettings.Values;
                    object videoInfo = string.Empty;
                    if(settings.TryGetValue(Constants.CurrentPlayingVideoInfo, out videoInfo))
                    {
                        string[] temp = videoInfo.ToString().Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                        if(temp.Length == 2)
                        {
                            VideoPlayPage.PageParams paras = new VideoPlayPage.PageParams();
                            paras.VideoId = Int32.Parse(temp[0]);
                            paras.StartPosition = TimeSpan.Parse(temp[1]);
                            paras.IsLanuchFromSerivice = true;

                            App.Instance.Frame.Navigate(typeof(VideoPlayPage), paras);
                            Window.Current.Activate();
                        }
                    }

                    break;
                case "playvideo":
                    if(IsInVideoPlayerPage())
                    {
                        var videoPlayer = App.Instance.Frame.Content as VideoPlayPage;
                        videoPlayer.Play();
                    }
                    break;
                case "pausevideo":
                    if(IsInVideoPlayerPage())
                    {
                        var videoPlayer = App.Instance.Frame.Content as VideoPlayPage;
                        videoPlayer.Pause();
                    }
                    break;
                case "stopvideo":
                    if(IsInVideoPlayerPage())
                    {
                        var videoPlayer = App.Instance.Frame.Content as VideoPlayPage;
                        videoPlayer.Stop();
                    }
                    break;
                default:
                    App.Instance.Frame.Navigate(typeof(MainPage), voiceCommand);
                    Window.Current.Activate();
                    break;
            }
        }
示例#3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            #if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
            #endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            Frame = rootFrame;

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (string.IsNullOrEmpty(e.Arguments) || e.Arguments.StartsWith("MGTV://"))
                {
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                else
                {
                    VideoPlayPage.PageParams paras = new VideoPlayPage.PageParams();
                    paras.VideoId = int.Parse(e.Arguments);
                    paras.IsLanuchFromSerivice = true;

                    rootFrame.Navigate(typeof(VideoPlayPage), paras);
                }
            }

            //var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
            //appView.SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
            //appView.SetPreferredMinSize(new Windows.Foundation.Size(1024, 778));
            //appView.VisibleBoundsChanged += AppView_VisibleBoundsChanged;

            Cortana.CortanaIntegrationHelper.CreateOrUpdateVoiceCommands();

            // Ensure the current window is active
            Window.Current.Activate();
        }