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

AudioSession category cause other audio source to be muted #529

Closed
2 tasks done
mrhery opened this issue Jun 25, 2020 · 12 comments
Closed
2 tasks done

AudioSession category cause other audio source to be muted #529

mrhery opened this issue Jun 25, 2020 · 12 comments
Assignees
Milestone

Comments

@mrhery
Copy link

mrhery commented Jun 25, 2020

Please read first!

Please use Public Google Group (mailing list) for general technical discussions and questions.

  • I have provided steps to reproduce (e.g. sample code or updated extra/renderer-and-libwebrtc-tests.js file).
  • I have provided third party library name and version, ios, Xcode and plugin version and adapter.js version if used.

Note: If the checkboxes above are not checked (which you do after the issue is posted), the issue will be closed.

Versions affected

  • Cordova version (9.0.0):
  • Plugin version (7.1.0):
  • iOS version (13.5.1):
  • Xcode version (11.5 - 11E608c):
  • WebRTC-adapter version (e.g. 7.4.0):
  • WebRTC Framework version (e.g. JSSip 3.1.2):

Description

I mixed a html page with video player (from cordova html page) and an iframe which have list of sounds. Whenever I play a sounds in the iframe, the video element in cordova html page goes mute automatically, but the video still working well. I checked remoteStream.getAudioTracks()[0].enabled it returns true, and the video tag muted attribute return false.

I noticed that iosrtc use RTCEAGLVideoView as the video view, and i tested even using Photos video on iPad, and play the sound on web browser simultaneously, the video mute too. And it is of course Apple standard (maybe). But having this issue on hybrid application is not acceptable. Because when the video call is running and notification audio played from the same (or iframe) html file will interfere (muting) the video call automatically.

It only happen to remoteStream only.

Steps to reproduce

  1. Create a cordova app
  2. Install the latest iosrtc plugin
  3. Create/overwrite the index.html; create an iframe (as URL below) and loads list of sound (audio player) and put 2 video tags with ids; my_self & remote_video each
  4. Start the webrtc process, get the local stream and put to my_self video id (using $("#my_self").prop("srcObject", localStream))
  5. When call received, accept the call and set the remote stream to remote_video video id.
  6. Now the call is running, try to play the audio inside of iframe, the video will automatically muted.

Expected results

The video should not mute automatically, it must played even audio player is played something. Or at least unmute after the other autdio play is stop.

Actual results

The video muted automatically, even after the audio has already finish playing.

URL of list of sound: https://workspace.my-intelligent.com/workspace/HTML5_Players/

@hthetiot hthetiot added the bug label Jun 28, 2020
@hthetiot hthetiot added this to the 6.0.13 milestone Jun 28, 2020
@hthetiot
Copy link
Contributor

hthetiot commented Jun 28, 2020

Thank you @mrhery for properly reporting the issue.
May be @ andrewvmail or @elmy33 have an idea how to fix that.

@andrewvmail
Copy link
Contributor

I never actually tried to play another HTML audio source while using this.
I did however long time ago use another cordova native plugin and played some sound while using this plugin and it worked fine. I don't remember which exactly maybe its this one https://github.com/floatinghotpot/cordova-plugin-nativeaudio

@hthetiot
Copy link
Contributor

@mrhery I dont think it will work in a iframe, however I did play sound properly using AudioContext (with AudioContext resume on touch) and createMediaElementSource from audio tag.

@hthetiot hthetiot added help wanted and removed bug labels Jun 30, 2020
@hthetiot hthetiot self-assigned this Jun 30, 2020
@mrhery
Copy link
Author

mrhery commented Jun 30, 2020

I found the solution. It is not the RTCEAGLVideoView issue, instead it's a AudioSession issue. I changed the options: .allowBluetooth to options: .mixWithOther solved it. I think the plugin should have the setting where developer can choose the AudioSession category.

I did not try on bluetooth device yet since I changed the AudioSession, so I cannot tell the side effects of changing it.

@andrewvmail
Copy link
Contributor

@mrhery you can do a PR similar to this #503
Maybe @hthetiot will merge

@hthetiot hthetiot reopened this Jul 17, 2020
@hthetiot hthetiot modified the milestones: 6.0.13, 6.0.14 Jul 17, 2020
@hthetiot
Copy link
Contributor

@mrhery you can do a PR similar to this #503
Maybe @hthetiot will merge

cc @mrhery

@hthetiot hthetiot changed the title RTCEAGLVideoView muted automatically when HTML audio played AudioSession category cause other audio source to be muted Jul 17, 2020
@hthetiot
Copy link
Contributor

I found the solution. It is not the RTCEAGLVideoView issue, instead it's a AudioSession issue. I changed the options: .allowBluetooth to options: .mixWithOther solved it. I think the plugin should have the setting where developer can choose the AudioSession category.

I did not try on bluetooth device yet since I changed the AudioSession, so I cannot tell the side effects of changing it.

You should not replace options but instead add to it to keep Bluetooth support.

let options: [AVAudioSession.CategoryOptions] = [.mixWithOthers, .allowBluetooth]

@hthetiot hthetiot modified the milestones: 6.0.14, 6.0.13 Jul 17, 2020
@hthetiot
Copy link
Contributor

Fixed by c49bdc5

@hthetiot
Copy link
Contributor

cc @andrewvmail let me know what you think of c49bdc5 in my point of view should not have major impact.

@hthetiot
Copy link
Contributor

Available on Master (NOT 6.0.13 RC1)

cordova plugin remove cordova-plugin-iosrtc --verbose
cordova plugin add https://github.com/cordova-rtc/cordova-plugin-iosrtc#master --verbose
cordova platform remove ios --no-save
cordova platform add ios --no-save

@andrewvmail
Copy link
Contributor

cc @andrewvmail let me know what you think of c49bdc5 in my point of view should not have major impact.

@hthetiot It looks fine but I'm concern about the mixed with others though. Googled around that and found
signalapp/Signal-iOS#2283 where they talk about removing that. It could be a variable thing people set maybe if they want to?

@andrewvmail
Copy link
Contributor

actually on second thought maybe thats fine since this plugin is polyfilling cordova to be like the browser.. your change takes it even closer

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

No branches or pull requests

3 participants