Skip to content
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

Merged
merged 9 commits into from Oct 18, 2020
Merged

Conversation

okan35
Copy link
Contributor

@okan35 okan35 commented Sep 24, 2020

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

Copy link
Member

@nielsvanvelzen nielsvanvelzen left a 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"
Copy link
Member

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() {
Copy link
Member

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();
Copy link
Member

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);
Copy link
Member

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.

Copy link
Member

@nielsvanvelzen nielsvanvelzen left a 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)
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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() {
Copy link
Member

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

Comment on lines 496 to 501
if (preferredVideoPlayerByPlayWith == PreferredVideoPlayer.VLC) {
useVlc = true;
} else if (preferredVideoPlayerByPlayWith == PreferredVideoPlayer.EXOPLAYER) {
// Make sure to not use VLC
useVlc = false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (preferredVideoPlayerByPlayWith == PreferredVideoPlayer.VLC) {
useVlc = true;
} else if (preferredVideoPlayerByPlayWith == PreferredVideoPlayer.EXOPLAYER) {
// Make sure to not use VLC
useVlc = false;
}
useVlc = preferredVideoPlayerByPlayWith == PreferredVideoPlayer.VLC;

@@ -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>
Copy link
Member

Choose a reason for hiding this comment

The 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>
<string name="play_with_exo_player">Play with ExoPlayer</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>
<string name="play_with_exo_player">Play with Exo Player</string>
<string name="play_with_external_app">Play with External App</string>
Copy link
Member

Choose a reason for hiding this comment

The 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>
<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());
Copy link
Member

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() {
Copy link
Member

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) {
Copy link
Member

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

@nielsvanvelzen nielsvanvelzen added this to In progress in v0.12.0 via automation Sep 26, 2020
Copy link
Member

@nielsvanvelzen nielsvanvelzen left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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() {

Copy link
Member

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.

@okan35
Copy link
Contributor Author

okan35 commented Oct 4, 2020

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 ?

@nielsvanvelzen
Copy link
Member

The FullDetailsActivity is shared for pretty much everything that exists and the play with button did show up for an artist for me.

@okan35
Copy link
Contributor Author

okan35 commented Oct 4, 2020

So basically if the current page is for music, we don't show play with button, right ?

@nielsvanvelzen
Copy link
Member

It happens now but it shouldn't

@nielsvanvelzen
Copy link
Member

I just tested it and it doesn't work for episodes

@okan35
Copy link
Contributor Author

okan35 commented Oct 18, 2020

I will check it now, try on my mibox what exactly is not working ?

@nielsvanvelzen
Copy link
Member

The normal play button showed up in the episode page instead of the play with button

Copy link
Contributor

Codacy 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nielsvanvelzen nielsvanvelzen merged commit 2e930f9 into jellyfin:master Oct 18, 2020
v0.12.0 automation moved this from In progress to Done Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v0.12.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants