Difference between revisions of "Trigger: Music/Sound playing"

m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<pre style="background-color: #EEEEEE; color: Black; border-radius: 10px; padding: 10px;">
+
<pre class="header-style">The Music/Sound Playing trigger fires when music or sound playback is started or stopped on the device. This allows you to automate actions based on audio playback state, such as adjusting volume or launching related apps.</pre>
Will fire when music or sound playback is started or stopped.
 
</pre>
 
<br>
 
'''Example Usage'''<br/>
 
  
<pre style="background-color: #AC2424; color: white; border-radius: 10px; padding: 10px;">
+
''' Options '''
Triggers
 
  
 +
* '''Music or Sound Started''' - Fires when audio playback begins on the device
 +
* '''Music or Sound Stopped''' - Fires when audio playback stops on the device
  
</pre><br>
+
''' Examples '''
<pre style="background-color: #1665B0; color: white; border-radius: 10px; padding: 10px;">
 
Actions
 
  
 +
''Example 1: Increase volume when music starts playing''
  
</pre><br>
+
  <pre class="trigger-style">Triggers
<pre style="background-color: green; color: white; border-radius: 10px; padding: 10px;">
 
Constraints
 
  
 +
Music/Sound Playing: Music or Sound Started</pre>
 +
  <pre class="action-style">Actions
  
</pre><br>
+
Set Volume: Media Volume 80%</pre>
<pre style="background-color: teal; color: white; border-radius: 10px; padding: 10px;">
+
  <pre class="constraint-style">Constraints
Local variables
 
  
 +
Headphones: Plugged In</pre>
  
</pre><br>
+
''Example 2: Turn off Bluetooth speaker when music stops''
 +
 
 +
  <pre class="trigger-style">Triggers
 +
 
 +
Music/Sound Playing: Music or Sound Stopped</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Wait 5 minutes
 +
Disable Bluetooth</pre>
 +
  <pre class="constraint-style">Constraints
 +
 
 +
Music Playing: Not Playing
 +
Bluetooth: Connected to Bluetooth Speaker</pre>
 +
 
 +
''' Notes '''
 +
 
 +
* This trigger uses a background service (DetectMusicService) to monitor audio playback state
 +
* The trigger detects audio from any app that uses the standard Android audio system
 +
* "Music or Sound" includes any audio stream, not just music (e.g., podcasts, videos, games)
 +
* The trigger fires when the audio focus state changes, which may not exactly match when you hear sound start or stop
 +
 
 +
''' See Also '''
 +
 
 +
* [[Constraint:_Music_Active|Music Active Constraint]]
 +
* [[Action: Control Media]]
 +
* [[Trigger: Media Button Pressed]]

Latest revision as of 20:57, 6 January 2026

The Music/Sound Playing trigger fires when music or sound playback is started or stopped on the device. This allows you to automate actions based on audio playback state, such as adjusting volume or launching related apps.

Options

  • Music or Sound Started - Fires when audio playback begins on the device
  • Music or Sound Stopped - Fires when audio playback stops on the device

Examples

Example 1: Increase volume when music starts playing

Triggers

Music/Sound Playing: Music or Sound Started
Actions

Set Volume: Media Volume 80%
Constraints

Headphones: Plugged In

Example 2: Turn off Bluetooth speaker when music stops

Triggers

Music/Sound Playing: Music or Sound Stopped
Actions

Wait 5 minutes
Disable Bluetooth
Constraints

Music Playing: Not Playing
Bluetooth: Connected to Bluetooth Speaker

Notes

  • This trigger uses a background service (DetectMusicService) to monitor audio playback state
  • The trigger detects audio from any app that uses the standard Android audio system
  • "Music or Sound" includes any audio stream, not just music (e.g., podcasts, videos, games)
  • The trigger fires when the audio focus state changes, which may not exactly match when you hear sound start or stop

See Also