Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue 310 - Added a new property, ignoreSilentSwitch. #403

Merged

Conversation

duhseekoh
Copy link
Contributor

When true, audio will play even when the silent switch on an iOS device is set to silent. When false, the audio will toggle with the silent switch. Sets the AVAudioSession to either playback or ambient.

Essentially, this... #310

If you guys are good with this I'll update the example project and readme.

…o will play even when the silent switch on an iOS device is set to silent. When false, the audio will toggle with the silent switch. Sets the AVAudioSession to either playback or ambient.
@mattapperson
Copy link
Contributor

I like this, but could you please update the readme noting this as an iOS only feature?

@duhseekoh
Copy link
Contributor Author

Yea, I'll add to the readme and update the example project in the next couple of days.

@mattapperson
Copy link
Contributor

Thanks! You rock!

@duhseekoh
Copy link
Contributor Author

Made the example app and readme changes:

image

@duhseekoh
Copy link
Contributor Author

Just realized, no matter what, this is going to take over the audio session settings, even if the property isn't set.

Hmm. It might make sense to have an enum setting instead of the boolean value.

Something like:

<Video ... audioMode= 'ambient' | 'playback'
// instead of
<Video ... ignoreSilentSwitch = true | false

That way if audioMode isn't set, then it won't take over apps audio just because a video exists in the app.

@SemonCat
Copy link

This feature is useful,

any reason not merge it?

@mattapperson
Copy link
Contributor

@SemonCat because as @duhseekoh pointed out, another API might be better

@larryranches
Copy link

@duhseekoh Great stuff! Do you have any updates on changing the ignoreSilentSwitch bool to a Api that accepts an enum?

@alexanderjarvis
Copy link

I'm also looking at something similar to this. What this doesn't handle is multiple videos.

@GeoffreyPlitt
Copy link

Any update on this?

@GeoffreyPlitt
Copy link

My company has created a $200 bounty for this PR, hoping someone can fix the issues soon. https://www.bountysource.com/issues/37409911-add-playwhilemuted-property

@bsiddiqui
Copy link

@duhseekoh are you still interested in merging this? If not, I'm happy to update the api

@duhseekoh
Copy link
Contributor Author

duhseekoh commented Apr 8, 2017 via email

@alexanderjarvis
Copy link

I created a version of this that handles multiple mounted video components and only stops the audio session when they are all unmounted: https://github.com/drivetribe/react-native-video/blob/fork/ios/RCTVideoAudio.m

It may not be exactly what you need but perhaps by posting it here it helps someone.

@larryranches
Copy link

@duhseekoh @bsiddiqui Are you guys planning on merging this PR soon?

Dom DiCicco and others added 2 commits April 19, 2017 12:25
This accounts for the case where the user does not want to modify the audio session from a particular video instance. The user would not use the ignoreSilentSwitch property at all in that case.
Also, the audio session will only be updated when the video is unpaused, instead of whenever the video component has updated props. This allows for multiple videos to be on the screen, with the most recent video unpaused (aka played) being the video that has control over the audio session.
@duhseekoh
Copy link
Contributor Author

duhseekoh commented Apr 19, 2017

Updates: Changed ignoreSilentSwitch to accept two string values, ignore and obey.
This accounts for the case where the user does not want to modify the audio session from a particular video instance. The user would not use the ignoreSilentSwitch property at all in that case.
Also, the audio session will only be updated when the video is unpaused, instead of whenever the video component has updated props. This allows for multiple videos to be on the screen, with the most recent video unpaused (aka played) being the video that has control over the audio session.

Would be great to have someone pull this down / into their project and test it.

@larryranches
Copy link

@duhseekoh Just tested this out and it's working perfectly in my project 👍 Thanks! Lets get this PR merged :)

@duhseekoh
Copy link
Contributor Author

Great. @mattapperson - Anything else needed for a merge?

@mattapperson mattapperson merged commit 98c51f1 into TheWidlarzGroup:master Apr 20, 2017
cmcewen pushed a commit to cmcewen/react-native-video that referenced this pull request Apr 27, 2017
…p#403)

* issue 310 - Added a new property, ignoreSilentSwitch. When true, audio will play even when the silent switch on an iOS device is set to silent. When false, the audio will toggle with the silent switch. Sets the AVAudioSession to either playback or ambient.

* Added ignoreSilentSwitch usage to example app and to readme

* Changed ignoreSilentSwitch to accept two string values, ignore and obey.
This accounts for the case where the user does not want to modify the audio session from a particular video instance. The user would not use the ignoreSilentSwitch property at all in that case.
Also, the audio session will only be updated when the video is unpaused, instead of whenever the video component has updated props. This allows for multiple videos to be on the screen, with the most recent video unpaused (aka played) being the video that has control over the audio session.
mattvot pushed a commit to calvium/react-native-video that referenced this pull request May 12, 2017
* master:
  Added flag for background mode (TheWidlarzGroup#563)
  issue 310 - Added a new property, ignoreSilentSwitch.  (TheWidlarzGroup#403)
  Add progressUpdateInterval to android-exoplayer (TheWidlarzGroup#540)
  Initial WPF Support (TheWidlarzGroup#385)
  added progressUpdateInterval to Android (TheWidlarzGroup#512)
  load new source if it is different (TheWidlarzGroup#502)
  Pausing progress if it was playing and the stating again (TheWidlarzGroup#526)
  bump android dependencies (TheWidlarzGroup#524)
  Update ExoPlayer to r2.2.0 (TheWidlarzGroup#505)
  Update readme (TheWidlarzGroup#497)
  [Android] App crash when unmounting video (TheWidlarzGroup#533)
  Fix/494 (TheWidlarzGroup#537)
  fix(RCTVideo.m): Fixed status bar disappearing issue
@akhan118
Copy link

Updates: Changed ignoreSilentSwitch to accept two string values, ignore and obey.
This accounts for the case where the user does not want to modify the audio session from a particular video instance. The user would not use the ignoreSilentSwitch property at all in that case.
Also, the audio session will only be updated when the video is unpaused, instead of whenever the video component has updated props. This allows for multiple videos to be on the screen, with the most recent video unpaused (aka played) being the video that has control over the audio session.

Would be great to have someone pull this down / into their project and test it.

Thank you for working on this feature , I have it a set it to where the video is paused as soon as the video is loaded and I'm observing that ignoreSilentSwitch="ignore" is not being evaluated as described above.

However If I removed paused={true} , ignoreSilentSwitch="ignore" works as intended.

How can I get ignoreSilentSwitch="ignore" to work when using paused={true} ?

example

 <Video
 source={{uri: videoUrl}}
  controls={true}
  ignoreSilentSwitch="ignore"
  fullscreenAutorotate={true}
  paused={true}
 />

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants