Run Flashphoner.init with different mediaProviders

cheinan

Member
Hello
In case of failure in play stream by webRTC i need to play it by WSPlayer without reloading the page or frame.
Is there a way i can run Flashphoner.init function again
with different mediaProviders without reloading the page?

Thanks
Cheinan
 
Last edited:

Max

Administrator
Staff member
Hello,

run Flashphoner.init function again with different mediaProviders without reloading the page
This would not work.

mediaProvider to be used can be specified in stream options when stream is created - that would not require reloading client page.

This worked with WCS v. 2701 and Chrome 63:
1. Specify preferredMediaProviders in Flashphoner.init() – have to start from "WSPlayer"
Code:
Flashphoner.init({
    receiverLocation: '../../dependencies/websocket-player/WSReceiver2.js',
    decoderLocation: '../../dependencies/websocket-player/video-worker2.js',
    preferredMediaProviders: ["WSPlayer", "WebRTC"]
});
2. On first playback attempt, create stream with mediaProvider set to "WebRTC"
Code:
var options = {
    name: streamName,
    display: remoteVideo,
    mediaProvider: "WebRTC"
};
session.createStream(options);
3. After the playback stream was stopped or failed, remove cached video element
Code:
$("video").remove();
4. On second playback attempt, create stream with mediaProvider set to "WSPlayer"
Code:
var options = {
    name: streamName,
    display: remoteVideo,
    mediaProvider: "WSPlayer"
};
session.createStream(options);
Please note that such fallback is not required if browser doesn’t support WebRTC.
 

cheinan

Member
Hi Max
Thank you for the replay.
It is working good, but i had a problem with the long time waiting for playback stream to be stopped or failed
STREAM_STATUS.STOPPED, STREAM_STATUS.FAILED
because it take long time about 12 seconds...
So i solved it by running a timer that wait 4 seconds and fire: session.disconnect()
And whan i get: SESSION_STATUS.DISCONNECTED i connect again with:
mediaProvider: "WSPlayer" and that way it is going mach faster...

I Have another problem:
When i use on the viewer side "WSPlayer" i could not control the sound on the viewer side.
On Chrome either using audio: false or stream.setVolume(0) in both cases i can still here the sound.
Any idea how can i mute the sound on viewer side when using "WSPlayer"?

Thanks
Cheinan
 

Max

Administrator
Staff member
Any idea how can i mute the sound on viewer side when using "WSPlayer"?
The voice control for WSPlayer won't work on iOS devices. You have to mute the device using corresponding hardware switch (iPhone, iPad).
However it works, for example on desktop browsers and somewhere else.
As you can see from the screenshot, it works on Desktop Google Chrome. The volume slider is active and working for WSPlayer.
https://wcs5-eu.flashphoner.com/client2/examples/demo/streaming/embed_player/sample.html
 

Attachments

cheinan

Member
Hi Max
The problem i have is on viewer side when using "WSPlayer" and setting:
var constraintsPlay = {
audio: false,
video: false
};
optionsPlay = {
name: streamInName,
display: remoteVideo,
constraints: constraintsPlay
};
session.createStream(optionsPlay).on(STREAM_STATUS.PLAYING, function (prvStream) ...
Is that on every platform: android or IOS or windows and in
Chrome, Firefox, Edge, safari ...
I can still see the video and here the sound! and the constraints do not work.
If i use on viewer side "WebRTC" the constraints is working good.
Any idea way this can happened?

Thanks
Cheinan
 
Last edited:

Max

Administrator
Staff member
Hello
Any idea way this can happened?
WSPlayer does not support constraints. The constraints are simply ignored by WSPlayer.
It does play audio+video, or if no audio it can play video only streams.
So i solved it by running a timer that wait 4 seconds and fire: session.disconnect()
Looks like an issue. We will check that on our end.
 

cheinan

Member
I have en idea how to solve the viewer side "WSPlayer" sound mute problem.
Please tell me if it can be practical.
I will connect the source webcam on the web page to Flashphoner only with video,
And in Iframe on that page i will do anther connection to Flashphoner only with audio,
So i will have for one broadcast side tow connections to Flashphoner, one only video and one only audio.

On the viewer side: if i need no audio i will connect him only to the video stream,
And if he need both video and audio i will connect him to the video stream and additionally in Iframe i will
connect him to the audio stream.

What do you think, is it practical solution?
Thanks
Cheinan
 
Last edited:

Max

Administrator
Staff member
Sounds good.
But you don't need to use iframe and second connection for audio and video publishing.
You can publish two streams within the same connection.
Code:
session.createStream({name:'stream1_audio', constraints:{audio:true,video:false}}).publish();
session.createStream({name:'stream1_video', constraints:{audio:false,video:true}}).publish();
Here you can see example for working with media devices (cams and microphones).
https://wcs5-eu.flashphoner.com/cli...dia_devices_manager/media_device_manager.html
 

Max

Administrator
Staff member
preferredMediaProviders in Flashphoner.init() – have to start from "WSPlayer"
The issue has been fixed in WCS v. 2824. WSPlayer can be specified as mediaProvider in stream options and video will be played, even if WSPlayer was not listed as first in preferredMediaProviders.
 
Top