public void OnPrepared(DownloadHelper helper) { for (int i = 0; i < downloadHelper.PeriodCount; i++) { TrackGroupArray trackGroups = downloadHelper.GetTrackGroups(i); for (int j = 0; j < trackGroups.Length; j++) { TrackGroup trackGroup = trackGroups.Get(j); for (int k = 0; k < trackGroup.Length; k++) { trackKeys.Add(new TrackKey(i, j, k)); var trackNameProvider = downloadTracker.TrackNameProvider; var trackName = trackNameProvider.GetTrackName(trackGroup.GetFormat(k)); trackTitles.Add(trackName); } } if (trackKeys.Count != 0) { builder.SetView(dialogView); } builder.Create().Show(); } }
private View BuildView(LayoutInflater inflater) { View view = inflater.Inflate(Resource.Layout.track_selection_dialog, null); ViewGroup root = (ViewGroup)view.FindViewById(Resource.Id.root); // View for disabling the renderer. _disableView = (CheckedTextView)inflater.Inflate( Android.Resource.Layout.SimpleListItemSingleChoice, root, false); _disableView.SetText(Resource.String.selection_disabled); _disableView.Focusable = true; _disableView.SetOnClickListener(this); root.AddView(_disableView); // View for clearing the override to allow the selector to use its default selection logic. _defaultView = (CheckedTextView)inflater.Inflate( Android.Resource.Layout.SimpleListItemSingleChoice, root, false); _defaultView.SetText(Resource.String.selection_default); _defaultView.Focusable = true; _defaultView.SetOnClickListener(this); root.AddView(inflater.Inflate(Resource.Layout.list_divider, root, false)); root.AddView(_defaultView); // Per-track views. bool haveSupportedTracks = false; bool haveAdaptiveTracks = false; _trackViews = new CheckedTextView[_trackGroups.Length][]; for (int groupIndex = 0; groupIndex < _trackGroups.Length; groupIndex++) { TrackGroup group = _trackGroups.Get(groupIndex); bool groupIsAdaptive = _trackGroupsAdaptive[groupIndex]; haveAdaptiveTracks |= groupIsAdaptive; _trackViews[groupIndex] = new CheckedTextView[group.Length]; for (int trackIndex = 0; trackIndex < group.Length; trackIndex++) { if (trackIndex == 0) { root.AddView(inflater.Inflate(Resource.Layout.list_divider, root, false)); } int trackViewLayoutId = groupIsAdaptive ? Android.Resource.Layout.SimpleListItemMultipleChoice : Android.Resource.Layout.SimpleListItemSingleChoice; CheckedTextView trackView = (CheckedTextView)inflater.Inflate( trackViewLayoutId, root, false); string txt = BuildTrackName(group.GetFormat(trackIndex)); trackView.SetText(txt, TextView.BufferType.Normal); if (_trackInfo.GetTrackFormatSupport(_rendererIndex, groupIndex, trackIndex) == RendererCapabilities.FormatHandled) { trackView.Focusable = true; trackView.Tag = Pair.Create(groupIndex, trackIndex); trackView.SetOnClickListener(this); haveSupportedTracks = true; } else { trackView.Focusable = false; trackView.Enabled = false; } _trackViews[groupIndex][trackIndex] = trackView; root.AddView(trackView); } } if (!haveSupportedTracks) { // Indicate that the default selection will be nothing. _defaultView.Text = Application.Context.GetString(Resource.String.selection_default_none); } else if (haveAdaptiveTracks) { // View for using random adaptation. _enableRandomAdaptationView = (CheckedTextView)inflater.Inflate( Android.Resource.Layout.SimpleListItemMultipleChoice, root, false); _enableRandomAdaptationView.Text = Application.Context.GetString(Resource.String.enable_random_adaptation); _enableRandomAdaptationView.SetOnClickListener(this); root.AddView(inflater.Inflate(Resource.Layout.list_divider, root, false)); root.AddView(_enableRandomAdaptationView); } UpdateViews(); return(view); }
public void OnTracksChanged(TrackGroupArray ignored, TrackSelectionArray trackSelections) { var mappedTrackInfo = trackSelector.CurrentMappedTrackInfo; if (mappedTrackInfo == null) { Log.Debug(TAG, "Tracks []"); return; } Log.Debug(TAG, "Tracks ["); // Log tracks associated to renderers. for (var rendererIndex = 0; rendererIndex < mappedTrackInfo.Length; rendererIndex++) { var rendererTrackGroups = mappedTrackInfo.GetTrackGroups(rendererIndex); var trackSelection = trackSelections.Get(rendererIndex); if (rendererTrackGroups.Length > 0) { Log.Debug(TAG, " Renderer:" + rendererIndex + " ["); for (int groupIndex = 0; groupIndex < rendererTrackGroups.Length; groupIndex++) { TrackGroup trackGroup = rendererTrackGroups.Get(groupIndex); var adaptiveSupport = getAdaptiveSupportString(trackGroup.Length, mappedTrackInfo.GetAdaptiveSupport(rendererIndex, groupIndex, false)); Log.Debug(TAG, " Group:" + groupIndex + ", adaptive_supported=" + adaptiveSupport + " ["); for (int trackIndex = 0; trackIndex < trackGroup.Length; trackIndex++) { var status = getTrackStatusString(trackSelection, trackGroup, trackIndex); var formatSupport = getFormatSupportString( mappedTrackInfo.GetTrackFormatSupport(rendererIndex, groupIndex, trackIndex)); Log.Debug(TAG, " " + status + " Track:" + trackIndex + ", " + Format.ToLogString(trackGroup.GetFormat(trackIndex)) + ", supported=" + formatSupport); } Log.Debug(TAG, " ]"); } // Log metadata for at most one of the tracks selected for the renderer. if (trackSelection != null) { for (var selectionIndex = 0; selectionIndex < trackSelection.Length(); selectionIndex++) { var metadata = trackSelection.GetFormat(selectionIndex).Metadata; if (metadata != null) { Log.Debug(TAG, " Metadata ["); printMetadata(metadata, " "); Log.Debug(TAG, " ]"); break; } } } Log.Debug(TAG, " ]"); } } // Log tracks not associated with a renderer. TrackGroupArray unassociatedTrackGroups = mappedTrackInfo.UnassociatedTrackGroups; if (unassociatedTrackGroups.Length > 0) { Log.Debug(TAG, " Renderer:None ["); for (int groupIndex = 0; groupIndex < unassociatedTrackGroups.Length; groupIndex++) { Log.Debug(TAG, " Group:" + groupIndex + " ["); var trackGroup = unassociatedTrackGroups.Get(groupIndex); for (int trackIndex = 0; trackIndex < trackGroup.Length; trackIndex++) { var status = getTrackStatusString(false); var formatSupport = getFormatSupportString( RendererCapabilities.FormatUnsupportedType); Log.Debug(TAG, " " + status + " Track:" + trackIndex + ", " + Format.ToLogString(trackGroup.GetFormat(trackIndex)) + ", supported=" + formatSupport); } Log.Debug(TAG, " ]"); } Log.Debug(TAG, " ]"); } Log.Debug(TAG, "]"); }
public void OnTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { for (int i = 0; i < trackGroups.Length; i++) { TrackGroup trackGroup = trackGroups.Get(i); for (int j = 0; j < trackGroup.Length; j++) { Metadata trackMetadata = trackGroup.GetFormat(j).Metadata; if (trackMetadata != null) { for (int v = 0; v < trackMetadata.Length(); v++) { Metadata.IEntry entry = trackMetadata.Get(v); switch (entry) { case ApicFrame apicFrame: byte[] bitmapData = apicFrame.PictureData.ToArray(); Bitmap bitmap = BitmapFactory.DecodeByteArray(bitmapData, 0, bitmapData.Length); var test1 = apicFrame.MimeType; break; case BinaryFrame binaryFrame: var test2 = binaryFrame.Data; break; case ChapterFrame chapterFrame: var test3 = chapterFrame.ChapterId; break; case ChapterTocFrame chapterTocFrame: var test4 = chapterTocFrame.IsRoot; break; case CommentFrame commentFrame: var test5 = commentFrame.Text; break; case GeobFrame geobFrame: var test6 = geobFrame.Data; break; case InternalFrame internalFrame: var test7 = internalFrame.Text; break; case PrivFrame privFrame: var test8 = privFrame.PrivateData; break; case TextInformationFrame textInformationFrame: var test9 = textInformationFrame.Value; break; case UrlLinkFrame urlLinkFrame: var test10 = urlLinkFrame.Url; break; default: break; } } } } } OnTracksChangedImpl?.Invoke(trackGroups, trackSelections); }