示例#1
0
        /// <summary>
        /// Creates a new <see cref="VideoPlayer"/> instance using specified <see cref="GraphicsDevice"/> and <see cref="VideoPlayerOptions"/>.
        /// </summary>
        /// <param name="graphicsDevice">The graphics device to use.</param>
        /// <param name="playerOptions">Player options.</param>
        public VideoPlayer([NotNull] GraphicsDevice graphicsDevice, [NotNull] VideoPlayerOptions playerOptions)
        {
            _stopwatch     = new Stopwatch();
            _playerOptions = playerOptions;

            _graphicsDevice      = graphicsDevice;
            _soundEffectInstance = new DynamicSoundEffectInstance(FFmpegHelper.RequiredSampleRate, FFmpegHelper.RequiredChannelsXna);
        }
示例#2
0
        public void playVideo(string options)
        {
            VideoPlayerOptions opts = JSON.JsonHelper.Deserialize <VideoPlayerOptions>(options);

            Uri uri = new Uri(opts.url);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                try
                {
                    this.play(opts.url);

                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
                }
                catch (Exception e)
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
                }
            });
        }
        /// <summary>
        /// Creates a new <see cref="DecodingThread"/> instance.
        /// </summary>
        /// <param name="videoPlayer">The parent <see cref="VideoPlayer"/>.</param>
        /// <param name="playerOptions">Player options.</param>
        internal DecodingThread([NotNull] VideoPlayer videoPlayer, [NotNull] VideoPlayerOptions playerOptions)
        {
            _videoPlayer   = videoPlayer;
            _playerOptions = playerOptions;

            // We need SynchronizationContext to post messages for us.
            // And gracefully, SynchronizationContext.Current is thread-local.
            var syncContext = SynchronizationContext.Current;

            if (syncContext == null)
            {
                syncContext = new SynchronizationContext();
                SynchronizationContext.SetSynchronizationContext(syncContext);
            }

            _mainThreadSynchronizationContext = syncContext;

            var thread = new Thread(ThreadProc);

            thread.IsBackground = true;
            SystemThread        = thread;
        }