Project

General

Profile

Feature #850

Custom hardware volume up/down buttons actions

Added by Marawan over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal

Description

Hi,

I can't vouch for most people but I never change the volume on the media center directly. I am sure most people have their media center (as a computer or android box) connected to a TV and maybe a home theater and so change the volume directly from their TV and/or home theater.

I would prefer if I could choose what the hardware buttons do. I would most probably map them to play/pause for volume down and maybe mute for volume up instead of having to open up the screen.

Thanks for your great work,

Marawan

History

#1 Updated by Tolriq over 1 year ago

Well you can write a plugin if you really really want to do that https://github.com/Tolriq/yatse-avreceiverplugin-api

And not most use Kodi volume as it means only one remote ;)

#2 Updated by Marawan over 1 year ago

ok I will most probably write a plugin for that.

Is there a way I can share that plugin (if you want) for everyone to use once it's done?

#3 Updated by Tolriq over 1 year ago

Well if your plugin works you can upload it to Play Store and even sell it (https://play.google.com/store/apps/details?id=dk.vindvejr.plugin.avreceiver.denon made that choice for example).

If your plugin is too specific for your needs, then maybe you can just push the sources to Github and I'll add a link somewhere so users can use your plugin as a base.

#4 Updated by Tolriq about 1 year ago

  • Status changed from New to Closed

Closing for now. If you need assistance please use the forum here so more can find and read.

#5 Updated by Marawan about 1 year ago

Hi,

I finally got the time to start this, one quick question as it is not documented, the settings passed between yatse and the plugin is a serialized text with no format right?

I mean yatse does not understand it and it is only there to be passed back to the plugin if it is reinstalled or something right?

thank you

#6 Updated by Marawan about 1 year ago

I just finished it but it's really ghetto, I pretty much just changed the volumeMinus call to playpause command. Don't really have time to make it clean for now, if you still want this ghetto version on github just tell me and I'll send it to you otherwise I'm happy just using it as is since I only needed to playpause on volume down when screen is off. If I end up making a clean version I'll let you know, what I had in mind was a version where you can choose from a list of commands what to map for each button (volume up and down).

thanks again for you help,

Marawan

#7 Updated by Tolriq about 1 year ago

Yes the settings is not managed by Yatse, it's just passed in/out for saving / restoration.

If you ever finish a better plugin then uploading to github could help some more users for sure.

#8 Updated by Marawan about 1 year ago

Hey I've been using my plugin for some time and there is something a bit strange. When the device goes in sleep mode sometimes yatse loses the "now playing" status. What I mean by that is that the media currently playing is not on yatse which means pressing the volume down on the device does not trigger the plugins volumeminus call. I don't know how yatse is implemented but don't you hold a partial wakelock when changing states? I am guessing you are subscribed to some kind of events that kodi sends when the media changes states or that you do polling, maybe the phone falls back into sleep before yatse has time to update its internal state (using a wakelock should fix that). Of course this is a blind guess. I feel like when the device goes in sleep mode yatse sometimes loses the media state. I've checked and the phone does have a wifi connection when this occurs so we can rule that as a cause.

I know this is probably low on your priority so I'm not expecting much but if you know what could be the cause or if there's a workaround it would be great.

Thanks

#9 Updated by Tolriq about 1 year ago

There's no wake lock when playing normal content on Kodi as there's absolutely no need for it.

Except killing battery, if you use lock screen controls, the OS keeps a wakelock to listen to the buttons when screen off and Yatse sends the commands.

In all cases volume handling is not tied to media playing or not.

#10 Updated by Marawan about 1 year ago

Hi,

Actually I didn't mean to hold a wakelock the entire time. I meant to hold a wakelock while processing incoming data or when sending data. This is actually done in almost all applications doing background processing because you can't rely on the system staying awake until you finish processing when an event is triggered. This doesn't impact the battery at all since you release the wakelock once you finish processing. Also volume handling can't be done if there is not content on kodi (whether it's paused or not). What I mean by that is that yatse doesn't receive volume events when kodi doesn't have any content on it. Anyway I just wanted to know if you knew the cause of this issue or if you have seen it before.

Thanks again

#11 Updated by Tolriq about 1 year ago

This is not how Kodi works ;)

I send play, Kodi returns OK. Actual play can start 10 mins later on some cases, I have no reason to wait so long for nothing.

#12 Updated by Marawan about 1 year ago

wow 10 mins? Are you sure you actually send the data and the application is just not on hold because the phone is in sleep mode?

What I mean: is the data actually sent to kodi and it's kodi that waits for 10 mins?

Or is it yatse that send the data 10 mins later? My guess is that it's yatse that is stuck since the phone is asleep because kodi runs on the server, I don't believe it can take 10 mins to answer to a simple play command.

If you monitor the network with wireshark or something you can make sure that it is indeed coming from kodi or not.

So you're telling me this is a limitation and there is nothing that could be done about it?

#13 Updated by Tolriq about 1 year ago

Just for information I code for Kodi since 9 years, I have provided numerous patches to Kodi too.

So please do try to teach me basics things that you may not even understood in the scope of Kodi.

As I said, JSON is asynchronous for most commands so I send a play command I have directly an OK. And nothing else. On some cases like long playlist slow Rpi the play can start start a very long time after, possibly 10 mins.

Worse when you play to an upnp player, the play can possibly never starts, so Yatse would wait infinitely for the play to start has there's no way to know that the play have not started.

Yatse is millions users best rated it's not luck I know what I do and it works to the maximum possible considering Kodi API.

#14 Updated by Marawan about 1 year ago

Ok, no need to get defensive, you have misunderstood my problem:

my plugin doesn't even receive the volumeMinus callback as I said earlier, so it has nothing to do with the API since yatse doesn't even send anything to kodi.

In the volumeMinus callback I send a playpause command but it never gets to the volumeMinus callback (it doesn't get called from kodi when I press the volume down button)

Here is the situation:

  1. I start a video on kodi with yatse and everything seems fine

  2. I press volume down to pause (it works)

  3. I press volume down to play (it works)

  4. I let it play for about 20 mins then decide to pause so I press volume down

  5. My plugin doesn't receive anything (yatse doesn't call volumeMinus)

  6. I open yatse to see it resynchronises with Kodi (meaning it lost the current media player and it says offline on the top)

  7. I need to switch to different host and get back to my current host for it to find my media player again

#15 Updated by Tolriq about 1 year ago

I'm not defensive, but when someone that does not understand something tries to give me lesson I put back things in the normal order.

http://yatse.tv/redmine/projects/yatse/knowledgebase/articles/20

But if Yatse says offline then your OS disconnect Wifi.

#16 Updated by Marawan about 1 year ago

I wasn't trying to give you lesson, we misunderstood each other, you were talking about the time it takes to play and I was talking about the time it takes to respond from kodi.

I may not understand completely how the kodi API works but I never talked about it. I simply was talking about android programming which I do understand.

Anyway no harm, it was just a misunderstanding.

I already mentioned the first thing I checked was the wifi connection, it's hard give logs when that happens since I need to be using yatse for a long time for that to happen.

I will activate debugging and once I reproduce the problem I will attach the logs.

Thanks

Also available in: Atom PDF

Go to top