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

Activate screensaver while playing music (or create option for it) #543

Open
hooger opened this issue Jan 15, 2019 · 7 comments
Open

Activate screensaver while playing music (or create option for it) #543

hooger opened this issue Jan 15, 2019 · 7 comments

Comments

@hooger
Copy link

hooger commented Jan 15, 2019

Hello guys,

first of all thank you for the addon! We really like it! It also helps me a lot, to disconnect my tv from internet.
My probelm is, when we use it to listen to music, the lighting of the tv bothers us. For this I wish the screensaver would start. However as a video is playing it is not possible. As a work around, I thought there should be a switch somewhere in the options, when True, tells kodi that it can go on with screensaver like when it is playing music. I thought "Audio only" would do exactly this, however it does not.

I tried to modify the code. I hoped to tell Kodi, that the current context is Files and not video (reason was to copy the option, making sure it exists). For this I added the corresponding line in settings.xml (which appeared and I was able to switch it) and added some changes to provider.py, set_content_type function so it looks like this:

def set_content_type(self, context, content_type):
        if context.get_settings().get_bool('youtube.enable.screensaver.during.video', True):
            content_type = kodion.constants.content_type.FILES

        context.set_content_type(content_type)
        if content_type == kodion.constants.content_type.VIDEOS:
            context.add_sort_method(kodion.constants.sort_method.UNSORTED,
                                    kodion.constants.sort_method.VIDEO_RUNTIME,
                                    kodion.constants.sort_method.DATE_ADDED,
                                    kodion.constants.sort_method.TRACK_NUMBER,
                                    kodion.constants.sort_method.VIDEO_TITLE,
                                    kodion.constants.sort_method.DATE)
        context.log_error('setting is: %s, context_type: %s' % (str(context.get_settings().get_bool('youtube.enable.screensaver.during.video', True)),content_type))

Although the log messages appear as I hope they should, the screensaver cannot be started neither as in Preview screensaver, nor when the timelimit elapses. This lead me to the realization that it is not that simple. Smile What else should be changed?

Although not mentioned here, I also modified const_settings.py and abstract_settings.py to add a function to get the value of the given setting. Later I haven't used it. I also added the necessary string to en_us but as my local settings does not match, it didn't appear.

Thank you for your answer in advance!
Best regards
hooger

@hooger
Copy link
Author

hooger commented Jan 15, 2019

I'm an idiot, at least in the code I used == instead of =... Tomorrow I check what I used in the acutal code. and update the issue accordingly.

@hooger
Copy link
Author

hooger commented Jan 16, 2019

I updated the first comment, I couldn't solve the problem on my own. Any idea how it should be tackled? I would gladly make the modification if you could tell me some hints what are the possibilities.
Thanks in advance!

@anxdpanic
Copy link
Collaborator

Not something I've ever looked into since I just turn the tv off and my avr continues playing the audio, so I'm not sure if it's possible off hand. I will look into it further for the next version, and post any updates here.

@hooger
Copy link
Author

hooger commented Jan 16, 2019

The following came to my mind: I guess somewhere you call the Kodi video player, which is---I guess---is the thing that stops the screensaver from activation. Do you think it's possible to have a subsetting for "Audio only" that makes the addon call the Kodi music player?

Ofc it would even be better to have a setting in the internal video player of Kodi, next to subtitles or something, that does exatcly that. Unfortunately in the Kodi code I couldn't find screensaver anywhere with a quick search so it seems even tougher. :)

@anxdpanic
Copy link
Collaborator

When I have the chance the first thing will be to take a look at a strictly audio add-on, and see if activating/using the screensaver is possible there.
If so then I'll work on explicitly configuring audio only items.

@anxdpanic
Copy link
Collaborator

@hooger
This is actually possible without any changes to the add-on by using keymapping, (https://kodi.wiki/view/Keymap)
The example below, is for 'alt+s'(start screensaver) and 'alt+h'(back to home window)

<keymap>
    <global>
        <keyboard>
            <s mod="alt">ActivateWindow(screensaver)</s>
            <h mod="alt">ActivateWindow(home)</h>
        </keyboard>
    </global>
</keymap>

Additional window ids can be found https://kodi.wiki/view/Window_IDs

@hooger
Copy link
Author

hooger commented Jan 26, 2019

I tried your suggestion, but it does not really work. ActivateWindow(screensaver) actually activates some black window (although my screensaver is set to Dim), which would be fine, however, after a couple of second the audio stops. I also tried ActivateScreensaver, however it does not activate during video (but it works when it's paused or not even started).

Although it does not solve my initial problem, now I found keymapping which is awesome! Thank you for that! :)

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

2 participants