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

Lacking documentation on how to change volume #164

Open
pal-tcook opened this issue Jun 4, 2021 · 10 comments
Open

Lacking documentation on how to change volume #164

pal-tcook opened this issue Jun 4, 2021 · 10 comments

Comments

@pal-tcook
Copy link

pal-tcook commented Jun 4, 2021

Hello, I'm adding a mute/unmute button to custom controls.

I've added custom controls to my layout file, and have provided a controller implementation to the kohii.setup lambda.

I've hooked up click listeners on 2 custom controls at the moment; a play button (that calls playback.manager.pause/play respectively) and a mute button which should update the volume info of a given video for which the mute button was called on.

I've checked out the documentation here:

https://eneim.github.io/kohii/

And couldn't find any examples of how to set the volume on playbacks.

However, I can see there is an API for setting volume, via the playback.manager.applyVolumeInfo.

Having read the documentation on this API, I'm a bit confused.

Say I want to unmute the video, I have been using this call:

playback.manager.applyVolumeInfo( VolumeInfo.DEFAULT_ACTIVE, playback, Scope.PLAYBACK )

Which, as far as I understand the source code, should be setting the volume on just this playback instance (because using Scope.Playback and passing playback as the target). However, the volume doesn't update to 1f (which I can see through debugging).

Could you provide information/documentation on how to do this?

p.s. I've also poked around in your sample apps, and couldn't find any usages of this part of the API either...

@pal-tcook
Copy link
Author

FYI - I am setting up my bucket with strategy = Strategy.MULTI_PLAYER

And I notice this from the documentation:

"NOTE: Multiple playbacks comes with a caveat. In Video playback, audio focus is an important aspect. The client needs to not only respect the audio focus given by system, but also to respect the audio focuses among a Video with the others in the same Application. Therefore, when the client enable MULTI_PLAYER Strategy, the library will forcefully mute the audio of all available Playbacks, regardless the number of Playbacks selected by the Selector. Changing to SINGLE_PLAYER or NO_PLAYER Strategy will switch everything back to normal."

Does this imply that you can not have audio playing if using strategy MULTI_PLAYER? Because to me, this implies that by default all videos will be muted, but doesn't indicate that I can't override this default behaviour via calls to playback.manager.applyVolumeInfo(..)

@pal-tcook
Copy link
Author

pal-tcook commented Jun 4, 2021

Hmmm, can confirm, if I set the strategy to Strategy.SINGLE_PLAYER then my code works (i.e. audio toggles on/off via calls to playback.manager.applyVolumeInfo(..))

This is... unfortunate, as the requirement for our feature is that we should allow multiple videos to play at once, but only one of the videos should be able to have it's audio active at any given moment. I.e. if there are 2 videos on screen, both start muted. User unmutes video 1, video 1 audio starts playing. User unmutes video 2, video 1 audio stops (ideally "automagically" via this library) and video 2 audio starts.

Could you be open to implementing such functionality? Would you consider reviewing a PR if I was to figure out how to make this work and open one? (I'd like to know this before I actually attempt this).

@eneim
Copy link
Owner

eneim commented Jun 5, 2021

@pal-tcook Regarding volume control, you can take a look here: https://github.com/eneim/kohii/tree/dev-v1/kohii-sample/src/main/java/kohii/v1/sample/ui/echo

This example demos how you can control the volume for each Playback individually, and store that info across config change.

To control the volume of the whole screen, you can take a look at Facebook example:

timelineVolume.observe(viewLifecycleOwner) {

I understand your concern about the lack document. I wish I have better time management to improve that.

--

Regarding the volume control in multiple player mode, you are correct that all the videos will be muted once you use the multiple player mode. I understand that you may want to have more Videos to play, and only one of them has Volume available. The challenge is to design a mechanism to support that from the library point of view. I can think about how it can be done (maybe adding some flags so that the client can switch to gain the control, but then it is your responsibility to manage the audio/audio focus effectively).

@pal-tcook
Copy link
Author

Hey @eneim - the lack of documentation (or rather, the lack of it being easily findable) on this specific feature is understandable given the complexity of the library and the fact it's a 1 man dev team, so don't take my comments as disparaging.

I will be running this "issue" past our product owner/designers to see if they can live with not having audio for videos on the parts of the app where we need MULTI_PLAYER functionality. It'd be a shame if this is a concrete requirement on our end, because it will mean we probably can not move forward with using this library (which then leaves us with the problem of "how to properly manage ExoPlayer instances for our videos which appear in a recycler view").

@eneim
Copy link
Owner

eneim commented Jun 11, 2021

@pal-tcook I see. Let me see how I can handle this. But it might be in a beta build so please consider the trade-off. Although it is understandable if you go with another solution, but I will try to give the user more choices.

@eneim
Copy link
Owner

eneim commented Jun 11, 2021

@pal-tcook Anyway, can you tell me ther version that you are using? It might be better to start investigating from there.

@pal-tcook
Copy link
Author

Hey @eneim - sorry for the slow reply!

I'm using version "1.2.0.2011008"

@Nurtaz440
Copy link

Nurtaz440 commented Jan 12, 2023

Hello, I want to mute my video with kohii how can do ? . Please help me to doing it. Without any buttons.

@eneim
Copy link
Owner

eneim commented Jan 18, 2023

Sorry for the lack of document, and also a late reply.

You can use

Manager.applyVolumeInfo API to change the volume of the whole list or of a single Playback. You can check this example: Facebook timeline

@mvn-vinhhuynh-dn
Copy link

mvn-vinhhuynh-dn commented Aug 6, 2023

@eneim
I facing this issue too.
I have a list of video, some item is single and some item is DUAL video.
Using MULTI_PLAYER and it can play video, but all of it seem not be muted, just volume always = 0.0f

Used applyVolumsInfo but still not fixed.

val manager =  kohiiPlayer.register(this, memoryMode = MemoryMode.HIGH)
                .addBucket(it, Strategy.MULTI_PLAYER) { candidates ->
                    candidates.take(2)
                }

            manager.applyVolumeInfo(
                volumeInfo = VolumeInfo(mute = false, volume = 0.6f),
                scope = Scope.BUCKET, target = it
            )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants