Using Device.volume and mute switch in a widget?

Hi there!

I was trying to make a widget that shows a variety of device statuses when I noticed something strange: Using SF Symbols I want to display if the volume is up or muted. Therefore I made a basic if statement

if ( Device.volume() > 0 ) {
    let volumeIcon = volumeStack.addImage(SFSymbol.named("speaker.wave.2").image)
    volumeIcon.imageSize = new Size(30,30)
    volumeIcon.tintColor = Color.white()
}

Strangely, when I preview the widget in the Scriptable app it works fine, but the actual widget on my home screen throws an “OSStatus error 561015905”. Unfortunately, I have no idea what could cause this. Does anyone have a clue?

Also, speaking of volume, is there any way to read the mute switch status?

1 Like

Hey,

I am getting the same error message when using Device.volume in a widget. But I have no clue if there is a workaround.
Did you find anything helpful related to this issue?

Same here with Device.volume().
But only in widget. Preview in App works.

Is there a solution?

Error: OSStatus — Apple API Errors