Videos play without sound

Help on issues you run into with LapTimer; in case you have a question on how to use LapTimer, use the forum "Using LapTimer" instead
Post Reply
cars4enjoying
20 or more Posts ★★★
20 or more Posts ★★★
Posts: 29
Joined: Wed Jun 01, 2022 2:00 pm

Videos play without sound

Post 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.
User avatar
Harry
Site Admin
Site Admin
Posts: 10524
Joined: Sun Sep 12, 2010 10:32 am
Location: Siegum, Germany
Contact:

Re: Videos play without sound

Post by Harry »

3rd party apps cannot play sounds in case the mute button is triggered. There are choices only Apple apps have. ;-)

- Harry
Image Image Image Image
cars4enjoying
20 or more Posts ★★★
20 or more Posts ★★★
Posts: 29
Joined: Wed Jun 01, 2022 2:00 pm

Re: Videos play without sound

Post 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?
User avatar
Harry
Site Admin
Site Admin
Posts: 10524
Joined: Sun Sep 12, 2010 10:32 am
Location: Siegum, Germany
Contact:

Re: Videos play without sound

Post 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
Image Image Image Image
cars4enjoying
20 or more Posts ★★★
20 or more Posts ★★★
Posts: 29
Joined: Wed Jun 01, 2022 2:00 pm

Re: Videos play without sound

Post 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
User avatar
Harry
Site Admin
Site Admin
Posts: 10524
Joined: Sun Sep 12, 2010 10:32 am
Location: Siegum, Germany
Contact:

Re: Videos play without sound

Post by Harry »

O.k., thanks!
Image Image Image Image
User avatar
Harry
Site Admin
Site Admin
Posts: 10524
Joined: Sun Sep 12, 2010 10:32 am
Location: Siegum, Germany
Contact:

Re: Videos play without sound

Post by Harry »

Will become available with 24.6.1 :-)
Image Image Image Image
cars4enjoying
20 or more Posts ★★★
20 or more Posts ★★★
Posts: 29
Joined: Wed Jun 01, 2022 2:00 pm

Re: Videos play without sound

Post by cars4enjoying »

Awesome thanks :)
Post Reply