Beispiel #1
0
        async Task iSceneAsyncInit.createResourcesAsync(Context context)
        {
            iDiligentWindow wnd = context.renderContext as iDiligentWindow;

            wnd?.setTitle("Vrmac graphics video player sample");

            mediaEngine.autoPlay = true;
            // string dir = RuntimeEnvironment.runningWindows ? windowsDirectory : linuxDirectory;
            // await mediaEngine.loadMedia( Path.Combine( dir, fileName ) );
            await mediaEngine.loadMedia(mediaFilePath);

            var streams = mediaEngine.mediaStreams;

            if (!streams.HasFlag(eMediaStreams.Video))
            {
                throw new ApplicationException("There's no video in that media file");
            }

            using (var dev = context.device)
                renderState = mediaEngine.createRenderer(context, dev, videoBorderColor);
            context.swapChainResized.add(this, onResized);

            ConsoleLogger.logInfo("VideoPlayerSample started playing the media");
            mouseHandler.subscribe(controller);
            controller.initialize(animation, mediaEngine);

            if (null != wnd)
            {
                string fileName = Path.GetFileName(mediaFilePath);
                wnd.windowTitle = "Vrmac graphics video player sample: " + fileName;
            }

            // Debug code below: wait 2 seconds, and seek
            // await Task.Delay( 2000 );
            // mediaEngine.setCurrentTime( TimeSpan.FromSeconds( 2278 ) );
        }