Skip to content

Commit

Permalink
Merge 92ed6d4 into 49a87b3
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mr authored Aug 14, 2024
2 parents 49a87b3 + 92ed6d4 commit f6b0ff8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ object SleepNotification {
muteMediaIntent.action = BROADCAST_ACTION_MUTE
val pendingMuteIntent = PendingIntent.getBroadcast(this, 0, muteMediaIntent, PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)


val notification = Notification.Builder(this, CHANNEL_ID_SLEEPTIMER)
.setCategory(Notification.CATEGORY_EVENT)
.setVisibility(Notification.VISIBILITY_PUBLIC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package com.maary.liveinpeace.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.media.AudioAttributes
import android.media.AudioAttributes.CONTENT_TYPE_MUSIC
import android.media.AudioAttributes.USAGE_MEDIA
import android.media.AudioFocusRequest
import android.media.AudioManager
import android.media.AudioManager.AUDIOFOCUS_GAIN
import com.maary.liveinpeace.Constants.Companion.BROADCAST_ACTION_MUTE
import com.maary.liveinpeace.Constants.Companion.BROADCAST_ACTION_SLEEPTIMER_CANCEL
import com.maary.liveinpeace.Constants.Companion.BROADCAST_ACTION_SLEEPTIMER_DECREMENT
Expand All @@ -20,6 +25,10 @@ class MuteMediaReceiver: BroadcastReceiver() {
do {
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 0)
} while (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) > 0)

val attributes = AudioAttributes.Builder().setUsage(USAGE_MEDIA).setContentType(CONTENT_TYPE_MUSIC).build()
val focusRequest = AudioFocusRequest.Builder(AUDIOFOCUS_GAIN).setAudioAttributes(attributes).setOnAudioFocusChangeListener {}.build()
audioManager.requestAudioFocus(focusRequest)
}

if (p1?.action == BROADCAST_ACTION_SLEEPTIMER_CANCEL ||
Expand Down

0 comments on commit f6b0ff8

Please sign in to comment.