コード例 #1
0
        /// <summary>
        /// Method executes PrepareAsync on ESPlayer. On success, notifies
        /// event PlayerInitialized. At this time player is ALREADY PLAYING
        /// </summary>
        /// <returns>bool
        /// True - AsyncPrepare
        /// </returns>
        private async Task StreamPrepare(CancellationToken token)
        {
            logger.Info("");

            try
            {
                using (await asyncOpSerializer.LockAsync(token))
                {
                    logger.Info("Player.PrepareAsync()");
                    await player.PrepareAsync(OnReadyToStartStream).WithCancellation(token);

                    stateChangedSubject.OnNext(PlayerState.Prepared);
                }
            }
            catch (InvalidOperationException ioe)
            {
                logger.Error(ioe);
                playbackErrorSubject.OnNext(ioe.Message);
            }
            catch (OperationCanceledException)
            {
                logger.Info("Operation Cancelled");
                DisableTransfer();
            }
            catch (Exception e)
            {
                logger.Error(e);
                playbackErrorSubject.OnNext("Start Failed");
            }
        }
コード例 #2
0
        private async Task <bool> ExecutePreparePlayback(CancellationToken token)
        {
            dataSynchronizer.Prepare();
            _dataClock.Start();
            var(needDataTcs, asyncHandler) = PrepareStreamStart(ESPlayer.StreamType.Audio, ESPlayer.StreamType.Video);

            using (token.Register(TerminateStreamStart, needDataTcs))
            {
                logger.Info("Player.PrepareAsync()");
                var prepareTask = player.PrepareAsync(asyncHandler);

                logger.Info("Player.PrepareAsync() Waiting for ready to prepare");
                await needDataTcs.Task;

                logger.Info("Player.PrepareAsync() Starting transfer");
                if (false == await StartTransfer(token))
                {
                    _dataClock.Stop();
                    return(false);
                }

                logger.Info("Player.PrepareAsync() Waiting for completion");
                await prepareTask.WithCancellation(token);

                logger.Info("Player.PrepareAsync() Done");

                // ***Workaround***
                // Tizen 5.0 first "completes" async operation, then changes internal state.
                // May result in Play being called before state allows it.
                await Task.Yield();
            }

            return(true);
        }
コード例 #3
0
        private async Task ExecutePrepareAsync(CancellationToken token)
        {
            _suspendResumeLogic.SetBuffering(true);
            esStreams[(int)StreamType.Video].RequestFirstDataPacketNotification();

            dataSynchronizer.Prepare();

            logger.Info("Player.PrepareAsync()");

            var asyncOp = player.PrepareAsync(EnableTransfer);

            dataSynchronizer.SetAsyncOperation(asyncOp);
            await asyncOp.WithCancellation(token);

            _suspendResumeLogic.SetBuffering(false);
            logger.Info("Player.PrepareAsync() Completed");
        }
コード例 #4
0
        /// <summary>
        /// Method executes PrepareAsync on ESPlayer. On success, notifies
        /// event PlayerInitialized. At this time player is ALREADY PLAYING
        /// </summary>
        /// <returns>bool
        /// True - AsyncPrepare
        /// </returns>
        private async Task PreparePlayback(CancellationToken token)
        {
            logger.Info("");

            try
            {
                using (await asyncOpSerializer.LockAsync(token))
                {
                    token.ThrowIfCancellationRequested();
                    dataSynchronizer.Prepare();

                    StartClockGenerator();

                    logger.Info("Player.PrepareAsync()");

                    var asyncOp = player.PrepareAsync(async stream => await StartTransfer(stream, token));
                    await asyncOp.WithCancellation(token);

                    logger.Info("Player.PrepareAsync() Done");
                }
            }
            catch (InvalidOperationException ioe)
            {
                logger.Error(ioe);
                playbackErrorSubject.OnNext(ioe.Message);
            }
            catch (Exception e)
                when(e is TaskCanceledException || e is OperationCanceledException)
                {
                    logger.Info("Operation Cancelled");
                    StopTransfer();
                    StopClockGenerator();
                }
            catch (Exception e)
            {
                logger.Error(e);
                playbackErrorSubject.OnNext("Start Failed");
            }
        }