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
Conversation
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.
Thanks for your PR. I did an initial review on the changed code and would like to request some changes to your implementation:
- Right now the playWithButton is added when the preferred player is "External". This should be changed to a new player type called "Choose" (string: "Always ask")
- In adition, the playWithButton should replace the play button
- When a player is chosen for playback the user preferences should not be changed, instead only the next playing file should use the chosen player.
<menu | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<item android:title="Play with Vlc" |
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.
All titles should use strings so they can be translated.
@@ -1260,6 +1267,19 @@ public void onClick(View v) { | |||
more.show(); | |||
} | |||
}); | |||
if (userPreferences.getValue().get(UserPreferences.Companion.getVideoPlayer()) == PreferredVideoPlayer.EXTERNAL) { | |||
playWithButton = new TextUnderButton(this, R.drawable.ic_add, buttonSize, 3, "Play with", new View.OnClickListener() { |
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.
"Play with" should use a string so it can be translated.
playWithButton = new TextUnderButton(this, R.drawable.ic_add, buttonSize, 3, "Play with", new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Toast.makeText(mApplication, "Play With Button", Toast.LENGTH_SHORT).show(); |
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.
This toast looks like it was intended for debugigng purposes, should probably remove it or replace it with a logger debug message.
switch (item.getItemId()) { | ||
|
||
case R.id.play_with_vlc: | ||
userPreferences.getValue().set(UserPreferences.Companion.getVideoPlayer(), PreferredVideoPlayer.VLC); |
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.
User preferences should never be changed without the user explicitly telling the application to do so. In this case you should find a way to set the player for the next play call without changing the setting.
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.
Some files have weird formatting or too many line breaks. Please check those and fix where necessary, but try to avoid reformatting the whole file.
* chosen player for play with button - changes every time user chooses a player with "play with" button | ||
*/ | ||
|
||
var chosenPlayer = Preference.enum("chosen_player",PreferredVideoPlayer.VLC) |
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
if (resumeButtonVisible) { | ||
mResumeButton.requestFocus(); | ||
} else { | ||
play.requestFocus(); | ||
if (!isPlayerPrefChoose) { |
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.
Use else if
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Probably easier to add an else
statement when checking if the play button should be shown
@@ -1260,6 +1276,18 @@ public void onClick(View v) { | |||
more.show(); | |||
} | |||
}); | |||
if (userPreferences.getValue().get(UserPreferences.Companion.getVideoPlayer()) == PreferredVideoPlayer.CHOOSE) { | |||
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 comment
The 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 playButton
property
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 comment
The reason will be displayed to describe this comment to others. Learn more.
if (preferredVideoPlayerByPlayWith == PreferredVideoPlayer.VLC) { | |
useVlc = true; | |
} else if (preferredVideoPlayerByPlayWith == PreferredVideoPlayer.EXOPLAYER) { | |
// Make sure to not use VLC | |
useVlc = false; | |
} | |
useVlc = preferredVideoPlayerByPlayWith == PreferredVideoPlayer.VLC; |
app/src/main/res/values/strings.xml
Outdated
@@ -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> | |||
<string name="play_with_exo_player">Play with Exo Player</string> |
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.
<string name="play_with_exo_player">Play with Exo Player</string> | |
<string name="play_with_exo_player">Play with ExoPlayer</string> |
app/src/main/res/values/strings.xml
Outdated
@@ -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> | |||
<string name="play_with_exo_player">Play with Exo Player</string> | |||
<string name="play_with_external_app">Play with External App</string> |
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.
<string name="play_with_external_app">Play with External App</string> | |
<string name="play_with_external_app">Play with external app</string> |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unused
@@ -1325,6 +1353,42 @@ public boolean onMenuItemClick(MenuItem item) { | |||
return false; | |||
} | |||
}; | |||
PlaybackController playbackController= new PlaybackController(MediaManager.getCurrentVideoQueue()); | |||
|
|||
PopupMenu.OnMenuItemClickListener playWithMenuListener = new PopupMenu.OnMenuItemClickListener() { |
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.
Mark private
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unused too
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.
- The "choose" option shows up for LiveTV. But I don't have LiveTV setup so I can't test if that works
- The "choose" button shows up on the artist page but music shouldn't do that
@@ -59,5 +60,11 @@ class SystemPreferences(context: Context) : SharedPreferenceStore( | |||
* Stores whether the sports filter is active in the channel guide or not | |||
*/ | |||
val liveTvGuideFilterSports = Preference.boolean("guide_filter_sports", false) | |||
|
|||
/** | |||
* chosen player for play with button - changes every time user chooses a player with "play with" button |
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.
* chosen player for play with button - changes every time user chooses a player with "play with" button | |
* Chosen player for play with button - changes every time user chooses a player with "play with" button. |
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() { | ||
//playButton becomes playWith button | ||
if (userPreferences.getValue().get(UserPreferences.Companion.getVideoPlayer()) == PreferredVideoPlayer.CHOOSE) { | ||
playButton = 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 comment
The reason will be displayed to describe this comment to others. Learn more.
playButton = new TextUnderButton(this, R.drawable.ic_add, buttonSize, 3, getString(R.string.play_with), new View.OnClickListener() { | |
playButton = new TextUnderButton(this, R.drawable.ic_play, buttonSize, 3, getString(R.string.play_with), new View.OnClickListener() { |
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.
This one isn't fixed yet. We should use the same icon.
I haven't even seen anything related to music, So I have to check this. I also don't listen to music on jellyfin either but I believe if the page is music we don't show play with button, right ? |
The FullDetailsActivity is shared for pretty much everything that exists and the play with button did show up for an artist for me. |
So basically if the current page is for music, we don't show play with button, right ? |
It happens now but it shouldn't |
I just tested it and it doesn't work for episodes |
I will check it now, try on my mibox what exactly is not working ? |
The normal play button showed up in the episode page instead of the play with button |
Here is an overview of what got changed by this pull request: Issues
======
- Added 1
Complexity increasing per file
==============================
- app/src/main/java/org/jellyfin/androidtv/ui/itemdetail/FullDetailsActivity.java 5
See the complete overview on Codacy |
@@ -839,6 +843,7 @@ public void onClick(DialogInterface dialog, int which) { | |||
private TextUnderButton queueButton = null; | |||
private TextUnderButton deleteButton = null; | |||
private TextUnderButton moreButton; | |||
private TextUnderButton playButton = null; |
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.
Feature to choose player from the menu where we have play button. I created this because some files play fine on vlc and some play fine on external app. It is better to have such button than going to settings and changing there.
Changes
Added play with button next to play button. This button will only be visible if preferred player is set external app.
Issues
#561