Beispiel #1
0
        public void Seek_Backward_Seeks(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var service = context.Service;

                for (var nextSeekTime = service.Duration - TimeSpan.FromSeconds(15);
                     nextSeekTime > TimeSpan.Zero;
                     nextSeekTime -= TimeSpan.FromSeconds(20))
                {
                    context.SeekTime  = nextSeekTime;
                    var seekOperation = new SeekOperation();
                    seekOperation.Prepare(context);
                    await seekOperation.Execute(context);
                }
            });
        }
Beispiel #2
0
        public void RepresentationChange_WhileSeeking_Succeeds(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var streams        = new[] { StreamType.Video, StreamType.Audio };
                var service        = context.Service;
                context.SeekTime   = null;  // Perform random seeks.
                var defaultTimeout = context.Timeout;
                foreach (var stream in streams)
                {
                    var descriptions = service.GetStreamsDescription(stream);

                    for (var i = 0; i < descriptions.Count; i++)
                    {
                        var seekOp = new SeekOperation();

                        // Wait for seekOp after ChangeRepresentation executes.
                        // Otherwise, position task of SeekOp may timeout as position may not be available
                        // till ChangeRepresentation completes.
                        context.Timeout = TimeSpan.Zero;
                        seekOp.Prepare(context);
                        var seekTask    = seekOp.Execute(context);
                        context.Timeout = defaultTimeout;

                        var changeOp = new ChangeRepresentationOperation
                        {
                            Index      = i,
                            StreamType = stream
                        };

                        var changeTask = changeOp.Execute(context);

                        await changeTask.WithCancellation(context.Token);
                        await seekTask.WithTimeout(context.Timeout).WithCancellation(context.Token);
                    }
                }
            });
        }
Beispiel #3
0
        public void Seek_EOSReached_StateChangedCompletes(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var service = context.Service;

                context.SeekTime  = service.Duration - TimeSpan.FromSeconds(5);
                var seekOperation = new SeekOperation();
                seekOperation.Prepare(context);

                var playbackErrorTask = service.PlaybackError()
                                        .FirstAsync()
                                        .ToTask();

                var clipCompletedTask = service.StateChanged()
                                        .AsCompletion()
                                        .Timeout(context.Timeout)
                                        .FirstAsync()
                                        .ToTask();

                await await Task.WhenAny(seekOperation.Execute(context), clipCompletedTask, playbackErrorTask);
            });
        }