-
-
Save abhiint16/165449a1a7d1a55a8f69d23718c603c2 to your computer and use it in GitHub Desktop.
this is my code
DefaultTrackSelector trackSelector = ExoPlayerManager.getSharedInstance(NewPlayerActivity.this).getTrackSelector();
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo != null) {
//CharSequence title = ((Button) view).getText();
//int rendererIndex = (int) v.getTag();
int rendererType = mappedTrackInfo.getRendererType(0);
boolean allowAdaptiveSelections =
rendererType == C.TRACK_TYPE_VIDEO
|| (rendererType == C.TRACK_TYPE_AUDIO
&& mappedTrackInfo.getTypeSupport(C.TRACK_TYPE_VIDEO)
== MappingTrackSelector.MappedTrackInfo.RENDERER_SUPPORT_NO_TRACKS);
Pair<AlertDialog, TrackSelection> dialogPair = TrackSelection
.getDialog(this, "Video", trackSelector, 0, NewPlayerActivity.this,
"");
dialogPair.second.setShowDisableOption(false);
dialogPair.second.setAllowAdaptiveSelections(allowAdaptiveSelections);
dialogPair.first.show();
}
i don't able to pass player.getVideoFormat() in below line
Pair<AlertDialog, TrackSelection> dialogPair = TrackSelection
.getDialog(this, "Video", trackSelector, 0, NewPlayerActivity.this,
"", HERE);
You'll have to open "exo_track_selection_view" XML and then change the package name (path name)to your custom TrackSelector.java
you'll find something like below in the XML
`
<X.Y.Z.TrackSelection
android:id="@+id/exo_track_selection_init_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" />
`
you need to change X.Y.Z.Trackselection to com.maxtv.activity.tv.TrackSelection
For your second issue that is, player.getVideoFormat(), just do one thing, replace the TrackSelection.java with the updated TrackSelection.java here https://gist.github.com/abhiint16/b473e9b1111bd8bda4833c288ae6a1b4
Pair<AlertDialog, NewTrackSelection> dialogPair = NewTrackSelection
.getDialog(PlayerActivity.this, "Video", trackSelector, 0, **PlayerActivity.this,**
"L", mPlayer.getVideoFormat());
I Got error GetReso field what should i write here? We need to pass activity.this or anything else ?
PlayerActivity.this,
If you see the above code of mine, VideoPayer is the class in which I have written this code in and I have also implemented GetReso interface in VideoPlayer, So if you're passing PlayerActivity.this, GetReso interface you should implement in PlayerActivity class.
can you share your Playeractivity class could not understand that getReso part. @abhiint16
GetReso is just an Interface. Check line no. 50s in this - https://gist.github.com/abhiint16/b473e9b1111bd8bda4833c288ae6a1b4
So, you can implement this interface in your PlayerActivity and hence you'll get a callback method
void getResoText(String resoText);
Now, this callback method will be called with the string value (Low, Med, High etc) whenever you change your resolution in TrackSelection.
getReso is just an Interface. Check line no. 50s in this - https://gist.github.com/abhiint16/b473e9b1111bd8bda4833c288ae6a1b4
So, you can implement this interface in your PlayerActivity and hence you'll get a callback method
void getResoText(String resoText);
Now, this callback method will be called with the string value (Low, Med, High etc) whenever you change your resolution in TrackSelection.
This is understand but Pair<AlertDialog, MyTrackSelection> dialogPair = MyTrackSelection
.getDialog(PlayerActivity.this, "Video Qualiry", mTrackSelector, 0,
getResoText(getResoText), mTrackSelector.toString(), mPlayer.getVideoFormat()); Pls check my sample. Let me know how to solved this
- You need to implement GetReso interface
- Then, override the provided method from GetReso interface.
then,
Pair<AlertDialog, MyTrackSelection> dialogPair = MyTrackSelection.getDialog(context, "Video Quality", mTrackSelector, 0, this, track_selection_text.getText().toString())
override the provided method from GetReso interface.
what should i write in this method?
Each video that you play has to provide resolution list to show it to your user. You need to debug in MyTackSelection's updateViews() method and see for trackGroups.length. For you, it seems that the length is 0
override the provided method from GetReso interface.
what should i write in this method?
Can you please elaborate what should i do ? Because if its normal list then its working fine,,,,
Could you please share me some sample code ?
The overridden method is used show the selected resolution to the UI.
Each video that you play has to provide resolution list to show it to your user. You need to debug in MyTackSelection's updateViews() method and see for trackGroups.length. For you, it seems that the length is 0
Track length getting 1.
You'll have to open "exo_track_selection_view" XML and then change the package name (path name)to your custom TrackSelector.java
you'll find something like below in the XML`
<X.Y.Z.TrackSelection android:id="@+id/exo_track_selection_init_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" />
`
you need to change X.Y.Z.Trackselection to com.maxtv.activity.tv.TrackSelection
So if i am doing this , i am not able to set my player
how to open exo_track_selection_dialog.xml and change to TrackSelection.
im getting this error
java.lang.ClassCastException: androidx.viewpager.widget.ViewPager cannot be cast to co.appmastery.worldbbtv.downloader.TrackSelection E/AndroidRuntime(30347): at co.appmastery.worldbbtv.downloader.TrackSelection.getDialog(TrackSelection.java:70) E/AndroidRuntime(30347): at co.appmastery.worldbbtv.PlayerActivity.test(PlayerActivity.java:909)
Any fix with the resoultion like youtube only 720 , 360 etc?
i got below error
in this line
TrackSelector.java
final TrackSelection selectionView = dialogView.findViewById(R.id.exo_track_selection_view);