Post

Replies

Boosts

Views

Activity

How can I detect when the mute switch has been toggled?
Hi, I’m working on an app that contains a feed of videos. The app has a global mute state flag that can be enabled or disabled. When the app mute state is toggled, I toggle the isMuted flag on my AVPlayers, and I also toggle the AVAudioSession category between .ambient and .playback. I enable/disable the mute state when the user taps a software button in my app. I also enable/disable the mute state when the user toggles the iPhone physical mute switch. This behavior is extremely similar to how mute state works in the Instagram app. However, my physical mute switch detection mechanism is quite hacky/finicky. I’m using a framework called Mute that I found on Github: https://github.com/akramhussein/Mute. It generally works, but it is far from a perfect solution, in part because it mis-triggers if the app hangs for a second (especially on older devices). How can I more reliably detect the state of the iPhone’s physical mute switch? It certainly must be possible, because mute switch detection in the Instagram app is much faster and more reliable than it is in my app. In case it’s useful, I submitted Feedback about this back in January (https://feedbackassistant.apple.com/feedback/7545314), but have not yet heard back. Thank you!
2
0
2.8k
Jun ’20
How to cache an HLS video while playing it
Hi, I'm working on an app where a user can scroll through a feed of short videos (a bit like TikTok). I do some pre-fetching of videos a couple positions ahead of the user's scroll position, so the video can start playing as soon as he or she scrolls to the video. Currently, I just pre-fetch by initializing a few AVPlayers. However, I'd like to add a better caching system. I'm looking for the best way to: get videos to start playing as possible, while making sure to minimize re-downloading of videos if a user scrolls away from a video and back to it. Is there a way that I can cache the contents of an AVPlayer that has loaded an HLS video? Alternatively, I've explored using AVAssetDownloadTask to download the HLS videos. My issue is that I can't download the full video and then play it - I need to start playing the video as soon as the user scrolls to it, even if it's not done downloading. Is there a way to start an HLS download with an AVAssetDownloadTask, and then start playing the video while it continues downloading? Thank you!
10
0
7.5k
Jun ’20
Unable to tap through a disabled SwiftUI View to a ViewController
I'm working on a SwiftUI app where I have a ZStack that has a ViewController (wrapped in a UIViewRepresentable view) underneath and a semitransparent SwiftUI view on top. I need to be able to tap through the SwiftUI view to the ViewController, but this does not seem to work. I've tried setting the SwiftUI view with .disabled(true) and .allowsHitTesting(false), but neither seem to resolve the issue. I've also tried using an overlay instead of a ZStack, but this did not help either. How do I put a SwiftUI View above a ViewController and allow taps/scrolls/other gestures to pass through to the ViewController? I made a sample project with 2 identical versions - it worked fine in the version with a SwiftUI view underneath, but did not work in the version with the ViewController underneath. SwiftUI only version (tapping on the red view passes through correctly): struct SwiftUIOnlyView: View {     var body: some View {         ZStack {             Color.white.onTapGesture {                 print("tapped \(Date())")             }             Color.red                 .disabled(true)                 .opacity(0.20)                 .frame(width: 100, height: 100, alignment: .center)         }     } } SwiftUI red view above a ViewController with a full screen button (tapping outside the red view works fine, but tapping on the red view does not pass through to the ViewController): struct SwiftUIAndViewControllerView: View {     var body: some View {         ZStack {             ViewControllerWrapperView()             Color.red                 .disabled(true)                 .opacity(0.20)                 .frame(width: 100, height: 100, alignment: .center)         }     } } struct ViewControllerWrapperView: UIViewControllerRepresentable {     func makeUIViewController(context: UIViewControllerRepresentableContext<ViewControllerWrapperView>) -> ViewController {         return ViewController()     }     func updateUIViewController(_ uiViewController: ViewController, context: UIViewControllerRepresentableContext<ViewControllerWrapperView>) {     } } class ViewController: UIViewController {     @IBAction func didTap(_ sender: Any) {         print("tapped \(Date())")     } }
4
0
9.6k
Jun ’20
Sign In with Apple does not work for user with @mac.com Apple ID
Hi, I have a user who cannot sign up for my app via Sign In with Apple. He reports that Sign In with Apple also does not work for him in other apps. His iPhone is signed into an Apple ID with an @mac.com email address. He gets the error message "Sign Up Not Completed" in the Sign in with Apple UI within my app. I noticed a similar report for a user with an @me.com Apple ID: https://developer.apple.com/forums/thread/122458?page=2 How can users with old @mac.com email addresses sign in?
1
0
591
Jul ’20