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

Enable Screensaver While Playing Audio Files in IINA Media Player #4954

Open
pritam12426 opened this issue May 27, 2024 · 4 comments · May be fixed by #4964
Open

Enable Screensaver While Playing Audio Files in IINA Media Player #4954

pritam12426 opened this issue May 27, 2024 · 4 comments · May be fixed by #4964

Comments

@pritam12426
Copy link

pritam12426 commented May 27, 2024

Summary:
I would like to request an enhancement for the IINA media player on Mac to enable the screensaver while playing audio files. This feature would allow users to conserve energy and prevent screen burn-in when only audio playback is needed.

Description:
Currently, IINA disables the screensaver for both video and audio playback. While this is beneficial for video files to prevent interruptions, it is not necessary for audio files.

@low-batt
Copy link
Contributor

I don't see a way to use the Screen Time Framework to turn off a display?

@pritam12426 pritam12426 changed the title Use screen time in iina when playing audio files Enable Screensaver While Playing Audio Files in IINA Media Player May 27, 2024
@low-batt
Copy link
Contributor

Thanks for rephrasing the issue. Sorry I didn't understand the initial request.

Indeed IINA does not distinguish between playing video vs. playing audio and always establishes a kIOPMAssertionTypeNoDisplaySleep assertion with the macOS power management system when playback is in progress.

The user should be able to control whether IINA prevents the display from sleeping separately for audio and video playback.

In general there can be a reason why an audio player might want to prevent the display from sleeping. For example, some players support displaying lyrics. There are requests for IINA to add that feature.

When you say "enable the screensaver" you mean not block it from automatically starting, yes?

@pritam12426
Copy link
Author

I don't have extensive knowledge in Swift or macOS development.

I noticed that the IINA application can distinguish between audio and video files. My request is: if a audio file does not contain subtitles or lyrics, could we enable the screensaver while playing audio?

In the future, it would be great if this feature could be added to IINA. This enhancement would allow users to enjoy their audio content without worrying about screen burn-in or unnecessary battery drain, while still providing a seamless viewing experience when subtitles or lyrics are present.

@low-batt
Copy link
Contributor

By "enable the screensaver" you don't mean "start the screen saver", you mean IINA should stop blocking the screen saver from starting after the inactivity timeout configured in the macOS Lock Screen setting, yes?

low-batt added a commit that referenced this issue May 30, 2024
This commit will:
- Add new settings preventDisplaySleepForAudio and
  preventDisplaySleepForVideo
- Change the PlayerCore checkCurrentMediaIsAudio method into an isAudio
  PlaybackInfo property
- Add a "Require display to stay on while actively playing video"
  checkbox to the settings window General tab
- Add a similar checkbox for playing audio
- Change the PlayerCore.checkStatusForSleep method to support the new
  settings
- Add logging to SleepPreventer
low-batt added a commit that referenced this issue May 30, 2024
This commit will:
- Add new settings preventDisplaySleepForAudio and
  preventDisplaySleepForVideo
- Change the PlayerCore checkCurrentMediaIsAudio method into an isAudio
  PlaybackInfo property
- Add a "Require display to stay on while actively playing video"
  checkbox to the settings window General tab
- Add a similar checkbox for playing audio
- Change the PlayerCore.checkStatusForSleep method to support the new
  settings
- Add logging to SleepPreventer
@low-batt low-batt linked a pull request May 30, 2024 that will close this issue
2 tasks
@low-batt low-batt linked a pull request May 30, 2024 that will close this issue
2 tasks
low-batt added a commit that referenced this issue Jun 5, 2024
This commit will:
- Add new settings preventScreenSaver and
  allowScreenSaverForAudio
- Change the PlayerCore checkCurrentMediaIsAudio method into an isAudio
  PlaybackInfo property
- Add a "Prevent screen saver from starting while playing"
  checkbox with a "Not while in Music Mode or only playing audio"
  subordinate checkbox to the settings window General tab
- Change the PlayerCore.checkStatusForSleep method to support the new
  settings
- Change SleepPreventer to use ProcessInfo activities instead of
  IOPMAssertionCreateWithName
- Add logging to SleepPreventer
- Remove the "Cannot prevent display sleep!" alert along with the
  associated suppressCannotPreventDisplaySleep preference.

This allows the user to control whether IINA prevents the screen saver
from starting when in music mode or just playing audio or allow the
screen saver to start and the display to power off and only prevent the
system from sleeping.

By default IINA will prevent the screen saver from starting when in
music mode or playing audio to match the current behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants