Flashphoner.init() multiple times

Hi!

Using WebSDK, I use this init in "play live video" function:
Flashphoner.init({
preferredMediaProviders:["MSE","WebRTC"]
});

Then I've got another function to "stream live video" started by:
Flashphoner.init();

Well, if I "stream live video" and then "play live video", the play video fails.
And in the other side, if I "play live video" and then "stream live video", the stream fails.

I understand that there are a fail in my code to init 2 Flashphoner with different parameters and only the first used is the valid. But then, how can I use parameters to play, but none parameters to stream? Is possible to "close" the "init" to open a new "init"?

Thank you very much for your help!

Greetings!
 

Max

Administrator
Staff member
Flashphoner.init() should be called strictly 1 time on page load.
This method is initializing API on the page.

Once initialization complete, you can create a new Session (websocket connection).
var session = Flashphoner.createSession();

Once the Session is ESTABLISHED you can create publish or play stream
session.createStream().publish(); or session.createStream().play();

See Two Way Streaming sample implementation

 
Hi!
Thank you for your reply.

But, if I init with:
Flashphoner.init({
preferredMediaProviders:["MSE","WebRTC"]
});
I'm unable to publish, only able to play. What can I do to offer both options (publish and play) with Init parameters?

Thank you!
 
Thank you MAX. Sorry, I don't explain it good.

If I started using:

Flashphoner.init():
3 play ok, 1 error
3 publish ok, 1 error
  • PLAY
    PC / Mac ok✅
    iOS ok✅
    Android ok✅
    Android 11 some devices(*), error: ICE Timeout❌
  • PUBLISH
    PC / Mac ok✅
    iOS ok✅
    Android ok✅
    Android 11 some devices(*), error: ICE Timeout❌
Flashphoner.init({preferredMediaProviders:["MSE","WebRTC"]}):
4 play ok, 0 error
0 publish ok, 4 error
  • PLAY
    PC / Mac ok✅
    iOS ok✅
    Android ok✅
    Android 11 some devices(*), error: ok✅
  • PUBLISH
    PC / Mac error: This provider doesn't support getMediaAccess❌
    iOS error: This provider doesn't support getMediaAccess❌
    Android error: This provider doesn't support getMediaAccess❌
    Android 11 some devices(*), error: This provider doesn't support getMediaAccess❌
Flashphoner.init({preferredMediaProviders:["WebRTC","MSE"]}):
3 play ok, 1 error
3 publish ok, 1 error
  • PLAY
    PC / Mac ok✅
    iOS ok✅
    Android ok✅
    Android 11 some devices(*), error: ICE Timeout❌
  • PUBLISH
    PC / Mac ok✅
    iOS ok✅
    Android ok✅
    Android 11 some devices(*), error: ICE Timeout❌
If I use the first option "Flashphoner.init()" without parameters, 95% of devices works, except Android 11 some devices(*). If I use "MSE, WEBRTC" works to play in ALL devices, Android some devices(*) included, but it's impossible to publish. And if I use "WEBRTC, MSE" order in parameters, then the problem is the same with no parameters.

(*) Some Android 11 devices: Samsung A series, Xiaomi & Huawei multiple models.

These test are in my code, but repeats in demo page too only changing de "init".

Thank you!
 

Max

Administrator
Staff member
Ah got it.

When you init preferredMediaProviders:["MSE","WebRTC"] , priority provider is MSE and MSE player will be mounted into the div. If MSE is not supported, WebRTC video will be mounted into the div, etc. MSE is a player. MSE can't publish any stream. That's why you get this error "This provider doesn't support getMediaAccess ".

When you init preferredMediaProviders:["WebRTC","MSE"], WebRTC code is mounted as priority provider. That's why you can either publish and play using this provider. Therefore if you are working with a player, you can choose providers and set a priority provider. However when you deal with publishing, you have to use WebRTC provider only.

Regarding Android 11 and ICE Timeout.
What is browser version?
Could you try to publish and play using WebRTC TCP.
 
Hi Max!

We've did testing in Android 11 devices(*) with "init()" only without params:

- Chrome 97.0.4692.98
Both with 'transport: "TCP"' or without it, gets error "FAILED Other: Failed by ICE timeout". Tested in Samsung A22, A21, A42, A52 and Xiaomi 11T.
Tested too using webview app, with the same result.
Tested using WIFI & 5G connection.

* Same Chrome version in other Android 11 devices, like OPPO RENO 6, OPPO FIND X2 works perfect in both options, and in Chrome and webview. In Android 10 or under works in all devices, all options and both Chrome and webview.

- Firefox 96.3.1 (Build #2015860755), 5e0953d24+
Works in both options, with or without 'transport: "TCP"'.

The problem is that all devices with this Chrome problem, includes all apps with webview and fails in all those apps.

Thank you!
 

Max

Administrator
Staff member
1. Please try to reproduce the problem with our demo server https://demo.flashphoner.com:8888/c...ming/two_way_streaming/two_way_streaming.html
2. If problem is not reproducing with demo server, please check if media ports on your server instance are available from the same network as a problem device: Port routing checking
3. If media ports on your server are available, please check if no firewalls, antiviruses and other stuff are running on the problem devices. Please check if the problem is reproducing on device out-of-the-box (after hard reset).
4. Please check if the problem is reproducing in other network (other mobile operator, other ISP)
5. Increase ICE timeout on server (the option needs server restart to be applied):
Code:
ice_keep_alive_timeout=60
If nothing helps, please reproduce the problem and collect a report using report.sh as described here. The report must include client debug logs and traffic dump. The traffic dump collection must be started before publishing stream form a problem device. Send the report archive using this form. If the archive size exceeds 25 Mb, please upload it to a public cloud storage and send the link using this form.
 

SLM

Member
See also this topic regarding Android (Samsung) device and ICE timeout:

This problem is still not fixed.

Chrome is increasingly producing more errors with Flashphoner while Firefox does not. We used to advise people to use Chrome for webrtc but lately we discourage people from using Chrome for this.
 

Max

Administrator
Staff member
This problem is still not fixed.
As you mentioned in this post, other WebRTC examples (AppRTC, TrickleICE) also does not work properly in Samsung browser. We use the standard WebRTC API (getUsersMedia, PeerConnection etc) in all the browsers. So the problem is not in WebSDK, but in WebRTC implementation in the browser.
Also, we need a stable reproduction to fix anything, and we can't reproduce the issue in latest Samsung browser build 16.0.6.23. Please try to reproduce the problem in the browser build, using latest WebSDK build 2.0.212, Two Way Streaming example.
If the problem is still reproducing, please collect a report as described here including client debug logs and traffic dump (which must be started to collect before stream publishing) ans send using this form.
 
Hi!
I've checked this problem is not available in all Samsung devices, only in A series and it's a webkit bug solved in Android reviews but not implemented by Samsung for this serie.
I solve it "in part", adding an if in javascript like if device model starts by "SM-A" then use createstream with mediaProvider "MSE" otherwise mediaProvider is WebRTC. This solution only works for playing video, not for publish, but is the only way to offer "anything" to these users without force them to install Firefox.

Waiting the upgrade of Samsung. Xiaomi solve it and OPPO too in the their reviews. Only Samsung A series is failed now.
 

Max

Administrator
Staff member
Waiting the upgrade of Samsung. Xiaomi solve it and OPPO too in the their reviews. Only Samsung A series is failed now.
Thank you for investigation.
Please, check if the problem is reproducing in latest Samsung browser build (they may fix it in proprietary browser). If this is not fixed yet, try also to publish VP8 in Media Devices example:
1644224888522.png

If codec stripping does not help, seems like Firefox is the only workaround for Samsung A series.
 
Hi!

Sorry, no luck :-(
I detected that one every X times (X = high random times) with Samsung, Chrome browser or WebView, the video runs and publish works. But only 1 every too much times. VP8 codec and any other option in "media devices" of demo page don't solve the problem.
Too, the "ICE Timeout" only shows if you try to send/receive WebRTC audio/video content.

Samsung, come on! ;-)
Hugs!
 

Max

Administrator
Staff member
Too, the "ICE Timeout" only shows if you try to send/receive WebRTC audio/video content.
Yes, ICE connection is establishing only for WebRTC publishing/playback. And seems this is broken yet on some of Samsung devices (but on good old flagships like S10/S10+ ICE works correctly both in Chrome and Samsung browser).
So, we have to wait for Samsung fix and use Firefox as workaround.
 
Top