Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Activate sound when the volume is changed (even in silent mode) #95

Merged
merged 2 commits into from
Jan 2, 2017

Conversation

askeland
Copy link
Collaborator

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

…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
@askeland
Copy link
Collaborator Author

@3lvis want to take a look? ;)

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: [])
}
catch let error {
print("Failed to start playback sound: \(error.localizedDescription)")
Copy link
Owner

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

Copy link
Collaborator Author

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")
Copy link
Owner

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.

@3lvis
Copy link
Owner

3lvis commented Jan 1, 2017

@askeland Nice fix! Only comment is regarding error handling, otherwise looks 👍

@askeland
Copy link
Collaborator Author

askeland commented Jan 1, 2017

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

@3lvis
Copy link
Owner

3lvis commented Jan 2, 2017

@askeland I see now :)

@3lvis 3lvis closed this Jan 2, 2017
@3lvis 3lvis reopened this Jan 2, 2017
@3lvis 3lvis merged commit b4e3047 into master Jan 2, 2017
@3lvis 3lvis deleted the feature/sound-when-volume-changed branch January 2, 2017 10:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants