I've pushed the code inside the promise of the play first viedo - but I still get the same error message:
console.log("Browser.IsWebRTC: " + Browser.isSafariWebRTC().toString());
if (Browser.isSafariWebRTC() || mediaProvidFP === "MSE") {
console.log("trying to run playFirstVideo Remote: ");
Flashphoner.playFirstVideo(remoteVideo, false, PRELOADER_URL).then(function () {
console.log("remote pass playfirst video, calling start");
if (Browser.isSafariWebRTC() && isMobile == "1") {
remoteVideo.style.width = showVidW + "px";
remoteVideo.style.height = TDshowVidID.style.height = "270px";
if (vidSideCut > 0) {
//לסדר פה שזה יקח ממשתנה קבוע ב Dict - marginRight or marginLeft
if (langID == "1") { remoteVideo.style.marginRight = "-" + vidSideCut + "px"; }
else { remoteVideo.style.marginLeft = "-" + vidSideCut + "px"; }
}
else {
remoteVideo.className = "display center";
}
}
/// moving the code into the promise:
if (Browser.isSafariWebRTC() && isMobile == "1") {
remoteVideo.style.width = showVidW + "px";
remoteVideo.style.height = TDshowVidID.style.height = "270px";
if (vidSideCut > 0) {
//לסדר פה שזה יקח ממשתנה קבוע ב Dict - marginRight or marginLeft
if (langID == "1") { remoteVideo.style.marginRight = "-" + vidSideCut + "px"; }
else { remoteVideo.style.marginLeft = "-" + vidSideCut + "px"; }
}
else {
remoteVideo.className = "display center";
}
}
var optionsPlayVid;
if (isWebRTCbrowser == "1") {
optionsPlayVid = {
name: streamInName,
display: remoteVideo,
constraints: constPlayVid,
mediaProvider: mediaProvid,
cacheLocalResources: false,
flashShowFullScreenButton: true
};
if (didConAgain == false && mediaProvid == "WebRTC") {
timerConAgainWS = setTimeout(function () { doConAgainWS(); }, 4000);
}
}
else {
optionsPlayVid = {
name: streamInName,
display: remoteVideo,
constraints: constPlayVid,
cacheLocalResources: false,
flashShowFullScreenButton: true
};
}
var session = Flashphoner.getSessions()[0];
console.log("calling create stream from withn the promise: ");
prvStream = session.createStream(optionsPlayVid).on(STREAM_STATUS.PLAYING, function (prvStream) {
streamInVid = prvStream;
clearTimeout(timerConAgainWS);
didConAgain = false;
DIVshowVidLoadID.style.display = "none";
TDshowVidID.style.display = "table-cell";
//remoteVideo.style.height = "" + showVidH.toString() + "px";
videoIN = document.getElementById(streamInVid.id());
//מארגן את נתוני הגובה והרוחב של הוידאו
var vidCanH = showVidH;
var vidCanW = showVidW;
//stackoverflow.com/questions/4129102/html5-video-dimensions
console.log("Add Event Listener");
videoIN.addEventListener("loadedmetadata", function (e) {
vidWidth = this.videoWidth, vidHeight = this.videoHeight;
if (isMobile == "1") {
vidCanH = Math.round(vidCanW / (vidWidth / vidHeight));
}
else {
vidCanW = Math.round(vidCanH * (vidWidth / vidHeight));
}
showVidW = vidCanW;
showVidH = vidCanH;
proportional = showVidW / showVidH; // w/h
console.log("863 - showVidW: " + showVidW + " - showVidH: " + showVidH);
videoIN.style.width = remoteVideo.style.width = vidCanW.toString() + "px";
videoIN.style.height = remoteVideo.style.height = TDshowVidID.style.height = vidCanH.toString() + "px";
}, false);
console.log("After ADd EVent Listener");
console.log("BrowserName: " + browserName + " isMobile: " + isMobile + " safariWebRTC: " + Browser.isSafariWebRTC().toString());
if (isSound == "1" && (mediaProvid == "WebRTC" || mediaProvid == "Flash") && (browserName != "safari" || isMobile == "0") && !Browser.isSafariWebRTC()) {
console.log("need to go to playSteamS.");
playStreamS();
}
console.log("doUserConInfo");
doUserConInfo(mediaProvid, "0");
console.log("After doUserConInfo");
//console.log(streamInVid.status());
//var streamResolution = streamInVid.videoResolution(); לברר על זה
//console.log("streamInVid size width: " + streamResolution.width + " height: " + streamResolution.height);
}).on(STREAM_STATUS.STOPPED, function () {
console.log("Play show Stream STOPPED");
if (didConAgain == false || mediaProvid != "WebRTC") {
doDisconnect(langArrOn[37], 2000, "3");
}
}).on(STREAM_STATUS.FAILED, function () {
console.log("Play show Stream FAILED");
if (didConAgain == false || mediaProvid != "WebRTC") {
doDisconnect(langArrOn[37], 2000, "4");
}
}).play();
});
}
and the console log:
[Log] 16:51:22 INFO webrtc - – "Initialized" (flashphoner.min.js, line 25)
[Log] 16:51:22 INFO websocket - – "Initialized" (flashphoner.min.js, line 25)
[Log] 16:51:22 INFO core - – "Initialized" (flashphoner.min.js, line 25)
[Log] userAskChat() (aaswuChatMTest.aspx, line 3436)
[Log] userAskChat() counterUAskChat: 1 (aaswuChatMTest.aspx, line 3517)
[Log] userAskChat() (aaswuChatMTest.aspx, line 3436)
[Log] userAskChat() counterUAskChat: 2 (aaswuChatMTest.aspx, line 3517)
[Log] userAskChat() (aaswuChatMTest.aspx, line 3436)
[Log] aaswuChatScriptTest.ascx - connectFphoner (aaswuChatMTest.aspx, line 2291)
[Log] mediaProvider: WebRTC (aaswuChatMTest.aspx, line 2292)
[Log] creating session: (aaswuChatMTest.aspx, line 2293)
[Log] connectFphoner() ESTABLISHED (aaswuChatMTest.aspx, line 2325)
[Log] Runnign playStream (aaswuChatMTest.aspx, line 2350)
[Log] Browser.IsWebRTC: true (aaswuChatMTest.aspx, line 2382)
[Log] trying to run playFirstVideo Remote: (aaswuChatMTest.aspx, line 2384)
[Log] remote pass playfirst video, calling start (aaswuChatMTest.aspx, line 2386)
[Log] calling create stream from withn the promise: (aaswuChatMTest.aspx, line 2447)
[Warning] RTCIceServer.url is deprecated, please use RTCIceServer.urls instead. (flashphoner.min.js, line 12)
[Log] Add Event Listener (aaswuChatMTest.aspx, line 2464)
[Log] After ADd EVent Listener (aaswuChatMTest.aspx, line 2496)
[Log] BrowserName: safari isMobile: 1 safariWebRTC: true (aaswuChatMTest.aspx, line 2537)
[Log] doUserConInfo (aaswuChatMTest.aspx, line 2542)
[Log] After doUserConInfo (aaswuChatMTest.aspx, line 2544)
[Log] 16:51:40 INFO webrtc - – "Autoplay detected! Trying to play a video with a muted sound..." (flashphoner.min.js, line 25)
[Log] 863 - showVidW: 480 - showVidH: 270 (aaswuChatMTest.aspx, line 2478)
[Error] Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
(anonymous function)
rejectPromise
play
(anonymous function) (flashphoner.min.js:25:178628)
promiseReactionJob