ryanheise / just_audio

Audio Player
1.06k stars 678 forks source link

Hide skip buttons in background service player controls #459

Closed bafplus closed 3 years ago

bafplus commented 3 years ago

Is your feature request related to a problem? Please describe. I dont use the skip buttons in my project. However, they still show in the background service (pulled from top). Is there a way to hide those skip buttons?

Describe the solution you'd like A tag or setting to hide/show such buttons

Describe alternatives you've considered A way to change the code without editing the source directly.

Additional context

ryanheise commented 3 years ago

One approach might be for the plugin to hide the skip buttons if sequence contains only one item. Would that work for you, or would you prefer an explicit option?

bafplus commented 3 years ago

Im using the supplied example as boilerplate. Instead of having a playlist, i'm serving streamingurls instead of audiofiles. Playlist in the example is more a media-library in that regard. So basically "just" playing one item only, without a playlist. But i dont know how you're suggestion handles that "playlist" in regards to sequence.

Op di 27 jul. 2021 om 14:21 schreef ryanheise @.***>:

One approach might be for the plugin to hide the skip buttons if sequence contains only one item. Would that work for you, or would you prefer an explicit option?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/459#issuecomment-887465818, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRCRWRA4XT5OWQDI7BWLTLTZ2QE7ANCNFSM5BCDTMRA .

ryanheise commented 3 years ago

I'm talking about the sequence getter:

https://pub.dev/documentation/just_audio/latest/just_audio/AudioPlayer/sequence.html

The proposed logic would be to show the skip buttons if sequence.length > 1. I take it in your app sequence.length == 1, correct?

bafplus commented 3 years ago

I think yes...but im a noob so i may be wrong. All i did was change the path to audiofile to a streamingurl, so basicly a endless audiofile. Yet i dont know how or if that affects the sequence since i still use the "playlist" as media library (without changing anything other then the source audiofile). Hope you understand my above answer :-)

You may pm me somehow if you want to take this out of the discussion here...

ryanheise commented 3 years ago

sequence is the playlist of the player. The skip buttons move forwards and backwards through that sequence. Try print(player.sequence.length); to confirm if you are unsure whether it is 1 in your app. Assuming it is 1 in your app, is this solution acceptable?

bafplus commented 3 years ago

In that case, no since i use the current sequence as library. Yet i do think it can work if i rework my code to set the library outside of the sequence scope.

But you're proposal should work IF sequence = 1 (just not in my usercase)

Op di 27 jul. 2021 om 15:08 schreef ryanheise @.***>:

sequence is the playlist of the player. The skip buttons move forwards and backwards through that sequence. Try print(player.sequence.length); to confirm if you are unsure whether it is 1 in your app. Assuming it is 1 in your app, is this solution acceptable?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/459#issuecomment-887497524, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRCRWSJU4ADBNJVO5IYGOLTZ2VVLANCNFSM5BCDTMRA .

ryanheise commented 3 years ago

If you do indeed use a sequence as a library but you don't want a playlist, how do you prevent sequence from acting as a playlist? Because after one item plays out it automatically advances to the next item in the sequence.

bafplus commented 3 years ago

Simple, i only use livestreams from online radiostations, so simply put, they won't end :-)

Op di 27 jul. 2021 om 15:41 schreef ryanheise @.***>:

If you do indeed use a sequence as a library but you don't want a playlist, how do you prevent sequence from acting as a playlist? Because after one item plays out it automatically advances to the next item in the sequence.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/459#issuecomment-887523429, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRCRWVKBMI6GT7CKPV6FNDTZ2ZSHANCNFSM5BCDTMRA .

ryanheise commented 3 years ago

I see.

If you fix that in your app, I assume you would be satisfied with the proposed solution?

bafplus commented 3 years ago

That that should work, so yes

IF i can fix that (noob in flutter ;-) )

Op di 27 jul. 2021 om 15:56 schreef ryanheise @.***>:

I see.

If you fix that in your app, I assume you would be satisfied with the proposed solution?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/459#issuecomment-887534538, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRCRWR23465XGCUW2HDQKDTZ23HBANCNFSM5BCDTMRA .

ryanheise commented 3 years ago

Can you try the the fix/queue branch and let me know if it works now for you?

bafplus commented 3 years ago

Sure...havent done that before...can you switch branch in pubspec.yaml? And how? :-)

ghost commented 3 years ago

@bafplus try this:

just_audio: 
   git:  
      url: https://github.com/ryanheise/just_audio.git 
      ref: fix/queue
      path: just_audio
ryanheise commented 3 years ago

Although since you want to test the just_audio_background package, you may use this:

just_audio_background: 
   git:  
      url: https://github.com/ryanheise/just_audio.git 
      ref: fix/queue
      path: just_audio_background
ryanheise commented 3 years ago

This is now published on pub, so you can do it the normal way. Let me know if you still encounter issues, otherwise I'll close if it is now working.

bafplus commented 3 years ago

I just tested it ( i think ) If i only have 1 item in sequence the skip buttons are gone, and thats indeed exactly what i need. That is what you changed right?

ryanheise commented 3 years ago

Yes, and the change also affects multi-item sequences too by disabling the next button when you're on the last item and disabling the previous button when you're on the first item. If the sequence length is 1, then there is no next or previous so both buttons are disabled.

Thanks for the feature request and testing.

bafplus commented 3 years ago

Happy to test! Thanks for helping.

One question tho, in my case sequence should always be 1. Whats the best way to "override" your code so it wil always be 1?

My next "project" will be chromecast support. But its very hard stuff since there are no (good) plugins (yet). Does anyone have a working implementation? Just selecting target device and "sling" the audiourl is enaugh in my usecase.

ryanheise commented 3 years ago

If you need help understanding how to have a sequence of length 1, please either ask for help on StackOverflow or consult the documentation.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.