protected virtual async Task <ISubProgram> LoadSubProgram(IProgramManager programManager, ContentType contentType, CancellationToken cancellationToken) { ISubProgram subProgram; try { var programs = await programManager.LoadAsync(cancellationToken).ConfigureAwait(false); var program = programs.Values.FirstOrDefault(); if (null == program) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): program not found"); throw new FileNotFoundException("Unable to load program"); } subProgram = TryFindBestQuality(program.SubPrograms, _quality); if (null == subProgram) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): no sub programs found"); throw new FileNotFoundException("Unable to load program stream"); } } catch (Exception ex) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): unable to load playlist: " + ex.Message); throw; } return(subProgram); }
protected virtual async Task <ISubProgram> LoadSubProgram(IProgramManager programManager, ContentType contentType, CancellationToken cancellationToken) { ISubProgram subProgram; try { IDictionary <long, Program> programs = await programManager.LoadAsync(cancellationToken).ConfigureAwait(false); Program program = Enumerable.FirstOrDefault <Program>((IEnumerable <Program>)programs.Values); if (null == program) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): program not found"); throw new FileNotFoundException("Unable to load program"); } subProgram = HlsPlaylistSegmentManagerPolicy.SelectSubProgram(program.SubPrograms); if (null == subProgram) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): no sub programs found"); throw new FileNotFoundException("Unable to load program stream"); } } catch (Exception ex) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): unable to load playlist: " + ex.Message); throw; } return(subProgram); }
protected virtual async Task<ISubProgram> LoadSubProgram(IProgramManager programManager, ContentType contentType, CancellationToken cancellationToken) { ISubProgram subProgram; try { var programs = await programManager.LoadAsync(contentType, cancellationToken).ConfigureAwait(false); var program = programs.Values.FirstOrDefault(); if (null == program) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): program not found"); throw new FileNotFoundException("Unable to load program"); } subProgram = SelectSubProgram(program.SubPrograms); if (null == subProgram) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): no sub programs found"); throw new FileNotFoundException("Unable to load program stream"); } } catch (Exception ex) { Debug.WriteLine("PlaylistSegmentManagerFactory.SetMediaSource(): unable to load playlist: " + ex.Message); throw; } return subProgram; }