-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature play with button #571
Changes from 4 commits
4612559
219545b
502c3ff
d4f5774
8ffba55
908f99c
401799c
893a3bf
ea11eaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.PopupMenu; | ||
import android.widget.Toast; | ||
|
||
import androidx.leanback.app.BackgroundManager; | ||
import androidx.leanback.app.RowsSupportFragment; | ||
|
@@ -40,9 +41,12 @@ | |
import org.jellyfin.androidtv.data.querying.StdItemQuery; | ||
import org.jellyfin.androidtv.data.querying.TrailersQuery; | ||
import org.jellyfin.androidtv.preference.UserPreferences; | ||
import org.jellyfin.androidtv.preference.constant.PreferredVideoPlayer; | ||
import org.jellyfin.androidtv.ui.IRecordingIndicatorView; | ||
import org.jellyfin.androidtv.ui.RecordPopup; | ||
import org.jellyfin.androidtv.ui.TextUnderButton; | ||
import org.jellyfin.androidtv.ui.playback.ExternalPlayerActivity; | ||
import org.jellyfin.androidtv.ui.playback.PlaybackController; | ||
import org.jellyfin.androidtv.ui.shared.BaseActivity; | ||
import org.jellyfin.androidtv.ui.shared.IMessageListener; | ||
import org.jellyfin.androidtv.ui.itemhandling.BaseRowItem; | ||
|
@@ -140,7 +144,7 @@ public class FullDetailsActivity extends BaseActivity implements IRecordingIndic | |
|
||
private Lazy<ApiClient> apiClient = inject(ApiClient.class); | ||
private Lazy<GsonJsonSerializer> serializer = inject(GsonJsonSerializer.class); | ||
|
||
private Lazy<UserPreferences> userPreferences = inject(UserPreferences.class); | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
@@ -839,6 +843,7 @@ public void onClick(DialogInterface dialog, int which) { | |
private TextUnderButton queueButton = null; | ||
private TextUnderButton deleteButton = null; | ||
private TextUnderButton moreButton; | ||
private TextUnderButton playWithButton = null; | ||
|
||
private void addButtons(int buttonSize) { | ||
String buttonLabel; | ||
|
@@ -888,18 +893,25 @@ public void onError(Exception exception) { | |
mDetailsOverviewRow.addAction(mResumeButton); | ||
boolean resumeButtonVisible = (mBaseItem.getBaseItemType() == BaseItemType.Series && !mBaseItem.getUserData().getPlayed()) || (mBaseItem.getCanResume()); | ||
mResumeButton.setVisibility(resumeButtonVisible ? View.VISIBLE : View.GONE); | ||
|
||
TextUnderButton play = new TextUnderButton(this, R.drawable.ic_play, buttonSize, 2, getString(BaseItemUtils.isLiveTv(mBaseItem) ? R.string.lbl_tune_to_channel : mBaseItem.getIsFolderItem() ? R.string.lbl_play_all : R.string.lbl_play), new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
play(mBaseItem, 0, false); | ||
} | ||
}); | ||
mDetailsOverviewRow.addAction(play); | ||
boolean isPlayerPrefChoose = userPreferences.getValue().get(UserPreferences.Companion.getVideoPlayer()) == PreferredVideoPlayer.CHOOSE; | ||
TextUnderButton play = null; | ||
if (!isPlayerPrefChoose) { | ||
play = new TextUnderButton(this, R.drawable.ic_play, buttonSize, 2, getString(BaseItemUtils.isLiveTv(mBaseItem) ? R.string.lbl_tune_to_channel : mBaseItem.getIsFolderItem() ? R.string.lbl_play_all : R.string.lbl_play), new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
play(mBaseItem, 0, false); | ||
} | ||
}); | ||
mDetailsOverviewRow.addAction(play); | ||
} | ||
|
||
if (resumeButtonVisible) { | ||
mResumeButton.requestFocus(); | ||
} else { | ||
play.requestFocus(); | ||
if (!isPlayerPrefChoose) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
play.requestFocus(); | ||
} | ||
|
||
} | ||
|
||
if (!mBaseItem.getIsFolderItem() && !BaseItemUtils.isLiveTv(mBaseItem)) { | ||
|
@@ -935,6 +947,8 @@ public void onClick(View v) { | |
|
||
} | ||
|
||
|
||
|
||
if (mBaseItem.getLocalTrailerCount() != null && mBaseItem.getLocalTrailerCount() > 0) { | ||
TextUnderButton trailer = new TextUnderButton(this, R.drawable.ic_trailer, buttonSize, getString(R.string.lbl_play_trailers), new View.OnClickListener() { | ||
@Override | ||
|
@@ -1136,6 +1150,8 @@ public void onClick(View v) { | |
|
||
mDetailsOverviewRow.addAction(mPrevButton); | ||
|
||
|
||
|
||
//now go get our prev episode id | ||
EpisodeQuery adjacent = new EpisodeQuery(); | ||
adjacent.setUserId(TvApp.getApplication().getCurrentUser().getId()); | ||
|
@@ -1260,6 +1276,18 @@ public void onClick(View v) { | |
more.show(); | ||
} | ||
}); | ||
if (userPreferences.getValue().get(UserPreferences.Companion.getVideoPlayer()) == PreferredVideoPlayer.CHOOSE) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably easier to add an |
||
playWithButton = new TextUnderButton(this, R.drawable.ic_add, buttonSize, 3, getString(R.string.play_with), new View.OnClickListener() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since either the play or play with button is shown you can probably reuse the |
||
@Override | ||
public void onClick(View view) { | ||
PopupMenu more = new PopupMenu(mActivity, view); | ||
more.inflate(R.menu.menu_details_play_with); | ||
more.setOnMenuItemClickListener(playWithMenuListener); | ||
more.show(); | ||
} | ||
}); | ||
mDetailsOverviewRow.addAction(playWithButton); | ||
} | ||
|
||
moreButton.setVisibility(View.GONE); | ||
mDetailsOverviewRow.addAction(moreButton); | ||
|
@@ -1325,6 +1353,42 @@ public boolean onMenuItemClick(MenuItem item) { | |
return false; | ||
} | ||
}; | ||
PlaybackController playbackController= new PlaybackController(MediaManager.getCurrentVideoQueue()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is unused |
||
|
||
PopupMenu.OnMenuItemClickListener playWithMenuListener = new PopupMenu.OnMenuItemClickListener() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mark private |
||
@Override | ||
public boolean onMenuItemClick(MenuItem item) { | ||
switch (item.getItemId()) { | ||
|
||
case R.id.play_with_vlc: | ||
userPreferences.getValue().set(UserPreferences.Companion.getChosenPlayer(),PreferredVideoPlayer.VLC); | ||
play(mBaseItem, 0, false); | ||
return true; | ||
case R.id.play_with_exo: | ||
userPreferences.getValue().set(UserPreferences.Companion.getChosenPlayer(),PreferredVideoPlayer.EXOPLAYER); | ||
play(mBaseItem, 0, false); | ||
return true; | ||
case R.id.play_with_external: | ||
userPreferences.getValue().set(UserPreferences.Companion.getChosenPlayer(),PreferredVideoPlayer.EXTERNAL); | ||
PlaybackHelper.getItemsToPlay(mBaseItem, false , false, new Response<List<BaseItemDto>>() { | ||
@Override | ||
public void onResponse(List<BaseItemDto> response) { | ||
if (mBaseItem.getBaseItemType() == BaseItemType.MusicArtist) { | ||
MediaManager.playNow(response); | ||
} else { | ||
Intent intent = new Intent(FullDetailsActivity.this, ExternalPlayerActivity.class); | ||
MediaManager.setCurrentVideoQueue(response); | ||
intent.putExtra("Position", 0); | ||
startActivity(intent); | ||
} | ||
} | ||
}); | ||
return true; | ||
|
||
} | ||
return false; | ||
} | ||
}; | ||
|
||
RecordPopup mRecordPopup; | ||
public void showRecordingOptions(String id, final BaseItemDto program, final boolean recordSeries) { | ||
|
@@ -1472,14 +1536,14 @@ public void onResponse(UserItemDataDto response) { | |
} | ||
|
||
protected void play(final BaseItemDto item, final int pos, final boolean shuffle) { | ||
final Activity activity = this; | ||
|
||
PlaybackHelper.getItemsToPlay(item, pos == 0 && item.getBaseItemType() == BaseItemType.Movie, shuffle, new Response<List<BaseItemDto>>() { | ||
@Override | ||
public void onResponse(List<BaseItemDto> response) { | ||
if (item.getBaseItemType() == BaseItemType.MusicArtist) { | ||
MediaManager.playNow(response); | ||
} else { | ||
Intent intent = new Intent(activity, mApplication.getPlaybackActivityClass(item.getBaseItemType())); | ||
Intent intent = new Intent(FullDetailsActivity.this, mApplication.getPlaybackActivityClass(item.getBaseItemType())); | ||
MediaManager.setCurrentVideoQueue(response); | ||
intent.putExtra("Position", pos); | ||
startActivity(intent); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -112,6 +112,19 @@ public PlaybackController(List<BaseItemDto> items, IPlaybackOverlayFragment frag | |||||||||||||||
useVlc = userPreferences.getValue().get(UserPreferences.Companion.getVideoPlayer()) == PreferredVideoPlayer.VLC; | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
public PlaybackController(List<BaseItemDto> items) { | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is unused too |
||||||||||||||||
mItems = items; | ||||||||||||||||
mApplication = TvApp.getApplication(); | ||||||||||||||||
mHandler = new Handler(); | ||||||||||||||||
|
||||||||||||||||
refreshRateSwitchingEnabled = DeviceUtils.is60() && userPreferences.getValue().get(UserPreferences.Companion.getRefreshRateSwitchingEnabled()); | ||||||||||||||||
if (refreshRateSwitchingEnabled) getDisplayModes(); | ||||||||||||||||
|
||||||||||||||||
// Set default value for useVlc field | ||||||||||||||||
// when set to auto the default will be exoplayer | ||||||||||||||||
useVlc = userPreferences.getValue().get(UserPreferences.Companion.getVideoPlayer()) == PreferredVideoPlayer.VLC; | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
public void init(VideoManager mgr) { | ||||||||||||||||
mVideoManager = mgr; | ||||||||||||||||
directStreamLiveTv = userPreferences.getValue().get(UserPreferences.Companion.getLiveTvDirectPlayEnabled()); | ||||||||||||||||
|
@@ -478,6 +491,16 @@ public void onResponse(StreamInfo internalResponse) { | |||||||||||||||
!internalResponse.getMediaSource().getDefaultAudioStream().getCodec().equals("dts"))) && | ||||||||||||||||
(!DeviceUtils.isFireTvStick() || | ||||||||||||||||
(vlcResponse.getMediaSource().getVideoStream() != null && vlcResponse.getMediaSource().getVideoStream().getWidth() < 1000)); | ||||||||||||||||
} else if (preferredVideoPlayer == PreferredVideoPlayer.CHOOSE) { | ||||||||||||||||
PreferredVideoPlayer preferredVideoPlayerByPlayWith = userPreferences.getValue().get(UserPreferences.Companion.getChosenPlayer()); | ||||||||||||||||
if (preferredVideoPlayerByPlayWith == PreferredVideoPlayer.VLC) { | ||||||||||||||||
useVlc = true; | ||||||||||||||||
} else if (preferredVideoPlayerByPlayWith == PreferredVideoPlayer.EXOPLAYER) { | ||||||||||||||||
// Make sure to not use VLC | ||||||||||||||||
useVlc = false; | ||||||||||||||||
} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
||||||||||||||||
System.out.println("PREFERRED PLAYER " + preferredVideoPlayerByPlayWith.name()); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
Timber.i(useVlc ? "Preferring VLC" : "Will use internal player"); | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<item android:title="@string/play_with_vlc" | ||
android:id="@+id/play_with_vlc" | ||
android:icon="@drawable/ic_heart" | ||
/> | ||
|
||
<item android:title="@string/play_with_exo_player" | ||
android:id="@+id/play_with_exo" | ||
android:icon="@drawable/ic_heart" | ||
/> | ||
<item android:title="@string/play_with_external_app" | ||
android:id="@+id/play_with_external" | ||
android:icon="@drawable/ic_heart" | ||
/> | ||
</menu> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -349,6 +349,7 @@ | |||||
<string name="pref_video_player_exoplayer">ExoPlayer</string> | ||||||
<string name="pref_video_player_vlc">libVLC</string> | ||||||
<string name="pref_video_player_external">External app</string> | ||||||
<string name="pref_video_player_choose">Always ask</string> | ||||||
<string name="pref_about_title">About</string> | ||||||
<string name="pref_media_player">Preferred media player</string> | ||||||
<string name="pref_next_up_timeout_summary">How long to wait before playing the next item</string> | ||||||
|
@@ -403,4 +404,8 @@ | |||||
<string name="not_deleted">Item NOT Deleted</string> | ||||||
<string name="turn_off">Turn this option off</string> | ||||||
<string name="just_one">Just this one</string> | ||||||
<string name="play_with_vlc">Play with Vlc</string> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<string name="play_with_exo_player">Play with Exo Player</string> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<string name="play_with_external_app">Play with External App</string> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<string name="play_with">Play with</string> | ||||||
</resources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use SystemPreferences