public async Task WhenCalledOnInvalidYoutubeId_DoesNotThrowPopulatesNull() { TmdbVideoModel videoModel = new TmdbVideoModel { Key = _invalidYoutubeKey }; await _ytExplodeVideoService.PopulateWithStreams(videoModel); Assert.Null(videoModel.Streams); }
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 { } }
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}"); }
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));
public abstract Task PlayVideo(TmdbVideoModel attachedVideo);