-
-
Notifications
You must be signed in to change notification settings - Fork 57
Activate sound when the volume is changed (even in silent mode) #95
Conversation
…ent mode (kind of like Snapchat). This is reset when video is closed, so volume must be changed again when new video starts if the user wants sound
@3lvis want to take a look? ;) |
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: []) | ||
} | ||
catch let error { | ||
print("Failed to start playback sound: \(error.localizedDescription)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably handle the errors as we are doing it in other places.
https://github.com/bakkenbaeck/Viewer/blob/master/Source/VideoView.swift#L91-L92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I was thinking about this as an "non-fatal" error, so I don't want it to fail the video playing. Or should it?
audioSession.addObserver(self, forKeyPath: VideoView.audioSessionVolumeKeyPath, options: .new, context: nil) | ||
self.shouldRegisterForOutputVolume = false | ||
} catch { | ||
print("Failed to activate audio session") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about error handling, here, too.
@askeland Nice fix! Only comment is regarding error handling, otherwise looks 👍 |
Yes, I was a little unsure about the error handling. Kind of just wanted to make it fail silently since it isn't exactly a critical feature |
@askeland I see now :) |
Activate sound when the volume is changed even if phone is in silent mode (kind of like Snapchat). This is reset when video is closed, so volume must be changed again when new video starts if the user wants sound