yeprem
New Member
We have this code
import React, { useEffect, useRef } from 'react';
import "./FlashphonerComponent.scss";
function FlashphonerComponent() {
useEffect(() => {
const Flashphoner = window.Flashphoner;
if (Flashphoner) {
var SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
var STREAM_STATUS = Flashphoner.constants.STREAM_STATUS;
console.log("STREAM_STATUS")
var session;
var PRELOADER_URL = "https://github.com/flashphoner/flas...xamples/demo/dependencies/media/preloader.mp4";
function init_api() {
Flashphoner.init({});
//Connect to WCS server over websockets
session = Flashphoner.createSession({
urlServer: "wss://stream.****.am" //specify the address of your WCS
})
.on(STREAM_STATUS.PLAYING, function(stream) {
console.log("playing");
// Get a reference to the video element
var videoElement = stream.getVideoElement();
// Set the volume (0.5 for half volume)
videoElement.volume = 0;
})
.on(SESSION_STATUS.ESTABLISHED, function(session) {
console.log("ESTABLISHED");
playClick();
});
}
var Browser = {
isSafari: function() {
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
},
}
function playClick() {
if (Browser.isSafari()) {
Flashphoner.playFirstVideo(document.getElementById("play"), true, PRELOADER_URL).then(function() {
playStream();
});
} else {
playStream();
}
}
function playStream() {
var options = {
name: "*",
display: document.getElementById("play")
};
var stream = session.createStream(options).on(STREAM_STATUS.PLAYING, function(stream) {
console.log("playing");
});
stream.play();
}
init_api()
}
}, []);
return (
<>
<div class="fp-Video">
<div id="play" class="display"></div>
</div>
</>
);
}
export default FlashphonerComponent;
And from browser stop the vide this is error
Unmuting failed and the element was paused instead because the user didn't interact with the document before. https://goo.gl/xX8pDD
Please help me run video autoplay
import React, { useEffect, useRef } from 'react';
import "./FlashphonerComponent.scss";
function FlashphonerComponent() {
useEffect(() => {
const Flashphoner = window.Flashphoner;
if (Flashphoner) {
var SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
var STREAM_STATUS = Flashphoner.constants.STREAM_STATUS;
console.log("STREAM_STATUS")
var session;
var PRELOADER_URL = "https://github.com/flashphoner/flas...xamples/demo/dependencies/media/preloader.mp4";
function init_api() {
Flashphoner.init({});
//Connect to WCS server over websockets
session = Flashphoner.createSession({
urlServer: "wss://stream.****.am" //specify the address of your WCS
})
.on(STREAM_STATUS.PLAYING, function(stream) {
console.log("playing");
// Get a reference to the video element
var videoElement = stream.getVideoElement();
// Set the volume (0.5 for half volume)
videoElement.volume = 0;
})
.on(SESSION_STATUS.ESTABLISHED, function(session) {
console.log("ESTABLISHED");
playClick();
});
}
var Browser = {
isSafari: function() {
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
},
}
function playClick() {
if (Browser.isSafari()) {
Flashphoner.playFirstVideo(document.getElementById("play"), true, PRELOADER_URL).then(function() {
playStream();
});
} else {
playStream();
}
}
function playStream() {
var options = {
name: "*",
display: document.getElementById("play")
};
var stream = session.createStream(options).on(STREAM_STATUS.PLAYING, function(stream) {
console.log("playing");
});
stream.play();
}
init_api()
}
}, []);
return (
<>
<div class="fp-Video">
<div id="play" class="display"></div>
</div>
</>
);
}
export default FlashphonerComponent;
And from browser stop the vide this is error
Unmuting failed and the element was paused instead because the user didn't interact with the document before. https://goo.gl/xX8pDD
Please help me run video autoplay
Last edited: