Ejemplo n.º 1
0
        /// <summary>
        /// Called when the CoreWindow object is created (or re-created).
        /// </summary>
        public void SetWindow(CoreWindow window)
        {
            ApplicationView.GetForCurrentView().Consolidated += AppView_Consolidated;

            // Register event handlers for app lifecycle.
            CoreApplication.Suspending += this.OnSuspending;
            CoreApplication.Resuming   += this.OnResuming;

            // Register for keypress notifications.
            window.KeyDown += this.OnKeyPressed;

            // Register for notification that the app window is being closed.
            window.Closed += this.OnWindowClosed;

            // Register for notifications that the app window is losing focus.
            window.VisibilityChanged += this.OnVisibilityChanged;

            // At this point we have access to the device and we can create device-dependent
            // resources.
            deviceResources = new DeviceResources();

            main = new _360VideoPlaybackMain(deviceResources);

            // Create a holographic space for the core window for the current view.
            // Presenting holographic frames that are created by this holographic space will put
            // the app into exclusive mode.
            holographicSpace = HolographicSpace.CreateForCoreWindow(window);

            // The DeviceResources class uses the preferred DXGI adapter ID from the holographic
            // space (when available) to create a Direct3D device. The HolographicSpace
            // uses this ID3D11Device to create and manage device-based resources such as
            // swap chains.
            deviceResources.SetHolographicSpace(holographicSpace);

            // The main class uses the holographic space for updates and rendering.
            main.SetHolographicSpace(holographicSpace);

            MediaSource source = MediaSource.CreateFromUri(sourceUri);

            mediaPlayer.MediaOpened += MediaPlayer_MediaOpened;
            mediaPlayer.Source       = source;// Windows.Media.Core.MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/video.mp4"));

            mediaPlayer.IsVideoFrameServerEnabled = true;
            mediaPlayer.IsLoopingEnabled          = true;
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            if (deviceResources != null)
            {
                deviceResources.Dispose();
                deviceResources = null;
            }

            if (main != null)
            {
                main.Dispose();
                main = null;
            }

            if (mediaPlayer != null)
            {
                mediaPlayer.Dispose();
                mediaPlayer = null;
            }
        }