Mute video on first play in WSPlayer

PhoneBot

New Member
Is there a way to mute the video on first play using the WSPlayer? I've tried the following and the video plays WITH sound, even though we've set the volume to 0. And looking at the documentation at https://flashphoner.com/docs/api/WCS5/client/web-sdk/latest/Session.html#~createStream there doesn't seem to be an option when creating the stream.

Code:
const streamParams = {
    name: "rtsp://localhost/VIDEO",
    display: "my-video",
    playWidth: 1280,
    playHeight: 720
};

let fpStream = session.createStream(streamParams)
    .on(Flashphoner.constants.STREAM_STATUS.PENDING, (stream) => {
        stream.setVolume(0);
    })
    .on(Flashphoner.constants.STREAM_STATUS.PLAYING, (stream) => {
        stream.setVolume(0);
    });

fpStream.play();
 

Max

Administrator
Staff member
Hello.
If you do not need sound at all, you can disable it via constraints:
Code:
const streamParams = {
name: "rtsp://localhost/VIDEO",
display: "my-video",
playWidth: 1280,
playHeight: 720,
constraints: {video:true, audio:false}
};
 

PhoneBot

New Member
Will this mean that the stream is forever muted? Ideally I want the viewer to be able to unmute the video later on.
 

PhoneBot

New Member
Doesn't seem work with through the api. Using the example below, sound still plays on load, even when we set the volume to zero.

HTML:
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test Player</title>
    <script type="text/javascript" src="https://demo.flashphoner.com:8888/shared/flashphoner.js"></script>
    <script>
        const SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
        const STREAM_STATUS = Flashphoner.constants.STREAM_STATUS;

        function init(){
            console.log("Initializing");
            Flashphoner.init({
                receiverLocation: "/shared/examples/demo/dependencies/websocket-player/WSReceiver2.js",
                decoderLocation: "/shared/examples/demo/dependencies/websocket-player/video-worker2.js",
                preferredMediaProviders: ["WSPlayer"]
            });

            Flashphoner.playFirstSound();

            Flashphoner.createSession({"urlServer": "wss://FLASHPHONER_SERVER"})
                .on(SESSION_STATUS.ESTABLISHED, (session) => {
                    console.log("Session ESTABLISHED");

                    const streamParams = {
                        name: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov",
                        display: document.getElementById("videoId"),
                        playWidth: 768,
                        playHeight: 424
                    };

                    let fpStream = session.createStream(streamParams)
                        .on(STREAM_STATUS.PENDING, (stream) => {
                            console.log("Stream PENDING");
                        })
                        .on(STREAM_STATUS.PLAYING, (stream) => {
                            console.log("Stream PLAYING");
                            stream.setVolume(0); // This doesn't mute the stream
                        })
                        .on(STREAM_STATUS.STOPPED, () => {
                            console.log("Stream STOPPED");
                        })
                        .on(STREAM_STATUS.FAILED, () => {
                            console.log("Stream FAILED");
                        })
                        .on(STREAM_STATUS.PLAYBACK_PROBLEM, () => {
                            console.log("Stream PLAYBACK_PROBLEM");
                        })
                        .on(STREAM_STATUS.NOT_ENOUGH_BANDWIDTH, (stream) => {
                            console.log("Stream NOT_ENOUGH_BANDWIDTH");
                        })

                    fpStream.play();
                })
                .on(SESSION_STATUS.DISCONNECTED, () => {
                    console.log("Session DISCONNECTED");
                })
                .on(SESSION_STATUS.FAILED, () => {
                    console.log("Session FAILED");
                });
        }

    </script>
</head>
<body onload="init()">
<h1>Video</h1>
<div id="videoId"></div>
</body>
</html>
However if I delay setting volume with the code below, sound still plays on load but its muted after 5 seconds
HTML:
setTimeout(()=>{stream.setVolume(0)}, 5000);
 

Max

Administrator
Staff member
We raised internal ticket WCS-1641 and let you know when fix it.
As workaround, you can use a minimum possible timeout (less then one second).
 
Top