Page 1 of 1

Videos play without sound

Posted: Sat Jun 04, 2022 1:05 pm
by cars4enjoying
When previewing videos in LapTimer I thought it was odd that there was never any sound, then I noticed that my iPhone was on silent (using the switch on the side in case is matters) and as soon as I took it off silent the sound was there.

So seems like a bug that LapTimer isn't playing sound like Photos etc does if silent mode is enabled. I'm assuming the app needs to tell iOS to ignore silent mode some how in the playback call it makes.

Re: Videos play without sound

Posted: Sat Jun 04, 2022 1:19 pm
by Harry
3rd party apps cannot play sounds in case the mute button is triggered. There are choices only Apple apps have. ;-)

- Harry

Re: Videos play without sound

Posted: Sat Jun 04, 2022 1:30 pm
by cars4enjoying
Just did some quick digging and wonder if that has changed now as this apple developer article seems to indicate that you can override this behaviour by configuring the playback category.

Code: Select all

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    let audioSession = AVAudioSession.sharedInstance()
     do {
        try audioSession.setCategory(.playback)
     } catch {
         print("Setting category to AVAudioSessionCategoryPlayback failed.")
     }

    return true
}
Does this help?

Re: Videos play without sound

Posted: Sat Jun 04, 2022 1:32 pm
by Harry
I think this is checking whether the phone is muted, not overriding mode of operation. Probably an item that could be displayed in LapTimer's Health Check. :-)

- Harry

Re: Videos play without sound

Posted: Sat Jun 04, 2022 1:42 pm
by cars4enjoying
From the description it sounds like it does override and allow sound playback in silent mode:
An audio session category defines the general audio behavior your app requires. AVFoundation defines several audio session categories that you can use, but most media playback apps require the playback category. This category indicates that audio playback is a central feature of your app. When you specify this category, your app’s audio continues with the Ring/Silent switch set to silent mode (iOS only). Enabling this category also allows your app to play background audio if you’re using the “Audio, AirPlay, and Picture in Picture” background mode

Re: Videos play without sound

Posted: Sat Jun 04, 2022 2:31 pm
by Harry
O.k., thanks!

Re: Videos play without sound

Posted: Sat Jun 04, 2022 2:44 pm
by Harry
Will become available with 24.6.1 :-)

Re: Videos play without sound

Posted: Sun Jun 05, 2022 9:26 pm
by cars4enjoying
Awesome thanks :)