const options = {
name: this.data.video.name,
display: this.$refs.video,
};
const playStream = (session) => {
this.session = session.createStream(options).on(STREAM_STATUS.PENDING, (stream) => {
const video = document.getElementById(stream.id());
if (!video.hasListeners) {
video.hasListeners = true;
video.addEventListener('playing', () => {
this.session.unmuteRemoteAudio();
});
}
}).on(STREAM_STATUS.PLAYING, (stream) => {
this.onStarted.push(stream);
this.isLoad = false;
}).on(STREAM_STATUS.FAILED, () => {
this.isShowMessageStream = true;
this.isLoad = false;
});
this.session.play();
};
// eslint-disable-next-line
Flashphoner.init({});
// eslint-disable-next-line
Flashphoner.createSession({ urlServer: this.serverAddr })
.on(SESSION_STATUS.ESTABLISHED, (session) => {
playStream(session);
});
В этом примере поток только воспроизводится. В нем же указано, как обойти autoplay policy, но с использованием jQueryPlayer - проблема не воспроизводится, так как там в одном и том же запускается стрим и воспроизводится
$("#volumeControl").slider({
range: "min",
min: 0,
max: 100,
value: currentVolumeValue,
step: 10,
animate: true,
slide: function(event, ui) {
//WCS-2375. fixed autoplay in ios safari
stream.unmuteRemoteAudio();
currentVolumeValue = ui.value;
stream.setVolume(currentVolumeValue);
}
}).slider("disable");
...
stream = session.createStream(options).on(STREAM_STATUS.PENDING, function (stream) {
$("#preloader").show();
var video = document.getElementById(stream.id());
if (!video.hasListeners) {
video.hasListeners = true;
//don't resize html5 video
if (video.nodeName.toLowerCase() !== "video") {
...
} else {
//WCS-2375. fixed autoplay in ios safari
video.addEventListener('playing', function () {
if (autoplay && stream.isRemoteAudioMuted()) {
$("#volumeControl").slider('value', 0);
}
});
}
}
}).on(STREAM_STATUS.PLAYING, function (stream) {
...
});
stream.play();
video
элемент на странице с указанием атрибута muted
...
<div class="col-sm-6">
<div class="text-center text-muted">Player</div>
<div class="fp-Video">
<div id="remoteVideo" class="display"><video id="videoMuted" muted autoplay></video></div>
</div>
...
var videoMuted = document.getElementById("videoMuted");
...
function playStream() {
var session = Flashphoner.getSessions()[0];
var streamName = $('#playStream').val();
session.createStream({
name: streamName,
display: remoteVideo,
remoteVideo: videoMuted
}).on(STREAM_STATUS.PENDING, function (stream) {
var video = videoControls;
video.addEventListener('playing', function () {
if (stream.isRemoteAudioMuted()) {
stream.unmuteRemoteAudio();
}
});
...
}).play();
}
...