Esempio n. 1
0
        public async Task WhenCalledOnInvalidYoutubeId_DoesNotThrowPopulatesNull()
        {
            TmdbVideoModel videoModel = new TmdbVideoModel {
                Key = _invalidYoutubeKey
            };
            await _ytExplodeVideoService.PopulateWithStreams(videoModel);

            Assert.Null(videoModel.Streams);
        }
Esempio n. 2
0
        public async Task WhenCalledOnValidYoutubeId_PopulatesObject()
        {
            TmdbVideoModel videoModel = new TmdbVideoModel {
                Key = _youtubetMovieTrailer
            };
            await _ytExplodeVideoService.PopulateWithStreams(videoModel);

            PrintStreamSetDetails(videoModel.Streams);

            Assert.True(videoModel.Streams.VideoStreams.Count() > 0);
        }
        /// <summary>Tries to populate the Streams property. Does not throw </summary>
        public async Task PopulateWithStreams(TmdbVideoModel attachedVideo)
        {
            try
            {
                var videoManifest = await _youtubeClient.Videos.Streams.GetManifestAsync(attachedVideo.Key);

                var muxedList = videoManifest.GetMuxed();

                var streams = muxedList.Select(stream => MapStreamInfo(stream));

                attachedVideo.Streams = new VideoStreamInfoSet(streams, DateTimeOffset.Now.AddMinutes(60)); // validity no longer provided by YtExplode, setting it arbitrarily
            }
            catch { }
        }
Esempio n. 4
0
        public async Task WhenCalledOnVideoWithInvalidVideo_DoesntCallPageService()
        {
            // Arrange
            TmdbVideoModel videoModel = new TmdbVideoModel {
                Key = _invalidYoutubeKey
            };
            await _ytExplodeVideoService.PopulateWithStreams(videoModel);

            //Act
            await _ytExplodeVideoService.PlayVideo(videoModel);

            //Assert
            _mockVideoPlayer.Verify(m => m.OpenVideoStreamDirectly(It.IsAny <string>()), Times.Never);
            _output.WriteLine($"Selected stream Url: {streamUrlResult}");
        }
Esempio n. 5
0
        public async Task WhenCalledOnVideoWithValidStreams_CallsPageService()
        {
            // Arrange
            TmdbVideoModel videoModel = new TmdbVideoModel {
                Key = _youtubetMovieTrailer
            };
            await _ytExplodeVideoService.PopulateWithStreams(videoModel);

            // Act
            await _ytExplodeVideoService.PlayVideo(videoModel);

            // Assert
            _mockVideoPlayer.Verify(m => m.OpenVideoStreamDirectly(It.Is <string>(str => !string.IsNullOrEmpty(str))), Times.Once);
            _output.WriteLine($"Selected stream Url: {streamUrlResult}");
        }
        public override async Task PlayVideo(TmdbVideoModel attachedVideo)
        {
            if (attachedVideo.Streams == null || attachedVideo.Streams.ValidUntil < DateTimeOffset.UtcNow)
            {
                await PopulateWithStreams(attachedVideo);
            }

            var selectedStream = attachedVideo.Streams == null ? null : _streamSelector.SelectVideoStream(attachedVideo.Streams.VideoStreams);

            if (selectedStream != null)
            {
                await _videoPlayer.OpenVideoStreamDirectly(selectedStream.StreamUrl);
            }
            else
            {
                await _fallback.PlayVideo(attachedVideo);
            }
        }
 public override async Task PlayVideo(TmdbVideoModel attachedVideo) =>
 await _videoPlayer.OpenYoutubeVideoInDeviceDefaultPlayer(GetVideoUrlFromId(attachedVideo.Key));
Esempio n. 8
0
 public abstract Task PlayVideo(TmdbVideoModel attachedVideo);