Opentok on streamCreated subscribe makes mobile chrome freeze - google-chrome

I am developing webRTC chat on opentok platform and vue.js. While everything is fine on desctop and mobile firefox browser, mobile chrome gets hung up when trying to subscribe to the event.stream. The weird thing is that if I activate developer tools then it will work on mobile chrome as expected so I can not debug error log on this one. I have been racking my brain on this for three days now. If anyone can help me I would appreciate it! Here is the relevant part of my code:
//start the live vicdeo sessiion
startLivevideoSession: function(session){
this.call = true; //set call to true
//initiate opentok session
this.LiveVideo_session = OT.initSession(session.apiKey, session.session)
//define on streamcreated method
this.LiveVideo_session.on('streamCreated', function(event) {
//this is the problem:
this.LiveVideo_session.subscribe(event.stream, 'stream_video1', {
height: '100%',
width: '100%',
showControls: true,
style: {
audioLevelDisplayMode: 'auto',
buttonDisplayMode: 'off',
nameDisplayMode: 'off',
videoDisabledDisplayMode: 'auto',
showArchiveStatus: false
}
}, this.handleError)
//problem ends
}.bind(this))
//define on sessionDisconnected method
this.LiveVideo_session.on("sessionDisconnected", function (event) {
if(this.call){
this.stopVideoButtonPress() //stop on going chat session if any
bus.$emit('showModal', "stopLivevideoSessionLeft"); //notify user that other user left the page
}
}.bind(this))
//define connect method
this.LiveVideo_session.connect(session.token, function(error) {
if(error){
this.handleError(error)
}else{
//if call mode is chat, do not publish chat at all
if(this.call_mode != 'chat'){
this.LiveVideo_session.publish(this.my_video); //publish my video to chatroom
}
//if testsession, publish stream also to stream_video1
if(this.testSession){
this.LiveVideo_session.publish(this.test_publisher)
}
}
}.bind(this));
//store session.premium_session to premium_session
this.premium_session = session.premium_session
//wait for UI elements to be created on page before OT.initPublisher
setTimeout(() => {
//setup my_video
if(this.call_mode == "audio") //if only audio is selected
var publisherOptions = {
videoSource: null,
name: this.connection_setup.stream_video_description+" (vain ääni)",
width: '100%',
height: '100%',
opaque: '1',
style: {
nameDisplayMode: "on",
audioLevelDisplayMode: "on",
}
}
else
//setup my_video for videochat
var publisherOptions = {
name: this.connection_setup.stream_video_description,
width: '100%',
height: '100%',
opaque: '1',
style: {
nameDisplayMode: "on",
audioLevelDisplayMode: "on",
}
}
//if call mode is chat, do not publish chat at all
if(this.call_mode != 'chat'){
console.log("call mode"+this.call_mode)
this.my_video = OT.initPublisher('my_video', publisherOptions, this.handleError)
}
//if testsession, publish stream also to stream_video1
if(this.testSession){
console.log("call testSession "+this.testSession)
publisherOptions.name = 'Sinun kuvasi keskustelukumppanin näkemänä';
this.test_publisher = OT.initPublisher('stream_video1', publisherOptions, this.handleError)
}
}, 600);
},

It might be Chrome that freezes, not opentok. See this chrome 61/android bug which includes a workaround of adding a border-radius

Related

autoplay not working on mobile devices YouTube video

The video is not working in autoplay on mobile, I know that the question has already been asked several times but the code was developed specifically for my site (by a developer who answers me more).
So I can't change it entirely, could I tell me what to add to make it work?
<script>
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
playerVars: {
'autoplay': 1,
'controls': 0,
'autohide': 1,
'wmode': 'opaque',
'showinfo': 0,
'loop': 1,
'mute': 1,
//'start': 15,
//'end': 110,
'playlist': '{{ product.metafields.left_image.left_image[forloop.index0] }}'
},
videoId: '{{ product.metafields.left_image.left_image[forloop.index0] }}',
events: {
'onReady': onPlayerReady
}
});
}
function onPlayerReady(event) {
event.target.mute();
$('#text').fadeIn(400);
//why this? Well, if you want to overlay text on top of your video, you
//will have to fade it in once your video has loaded in order for this
//to work in Safari, or your will get an origin error.
}
//this pauses the video when it's out of view, just wrap your video in .m-//video
$(window).scroll(function() {
var hT = $('.m-video').height(),
wS = $(this).scrollTop();
if (wS > hT) {
player.pauseVideo();
}
else {
player.playVideo();
}
});
</script>
you can add the following code in the end of the onPlayerReady function:
if(window.innerWidth < 768) {
player.playVideo();
}
This code will start playing the video on mobile devices by checking the screen size.

Colorbox Plugin not allowing clicks on the Parent webpage after loading and running

How do I prevent the colorbox plugin from blocking clicks and keyboard inputs after it loads and runs? I've configured the code part correctly but now i'm running into this problem. I want users to be able to access the webpage while this digital ad billboard shows ads but it doesn't block them from using the website. Thanks. The billboard is running on the site http://infinitechllc.cloud
```<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://www.jacklmoore.com/colorbox/jquery.colorbox.js"></script>
<script>
function openColorBox(){
$.colorbox({
iframe: true,
width: "300px",
height: "200px",
left: "0%",
top: "0%",
href: "//zuphaims.com/afu.php?zoneid=3864474",
onLoad: function() {
$('#cboxClose').remove();
setTimeout(function(){
$(window).colorbox.close();
}, 31536030000)
}
});
}
function countDown(){
seconds--
$("#seconds").text(seconds);
if (seconds === 0){
openColorBox();
clearInterval(i);
}
}
var seconds = 5,
i = setInterval(countDown, 20000);
var seconds = setInterval(openColorBox, 10000);
</script>
<script>
$('#ColorBox').off('click');
</script>```

cordova-admob-pro not working on iPhone

I am trying to use this cordova plugin for admob ads with Intel XDK:
cordova-admob-pro
So far, for android devices its perfect, but it does not seem to work when exported to iOS apps... Did somebody fix this issue?
Thanks
I had this problem but solved it by using another plugin, from here https://github.com/sunnycupertino/cordova-plugin-admob-simple
To install it:
cordova plugin add cordova-plugin-admob-simple
Integration is as follows:
-Add the following javascript functions, put in your own ad code, play with the variables if you want.
-Call initAd() from onDeviceReady(), and showBannerFunc() and showInterstitialFunc() to show ads.
//initialize the goodies
function initAd(){
if ( window.plugins && window.plugins.AdMob ) {
var ad_units = {
ios : {
banner: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx', //PUT ADMOB ADCODE HERE
interstitial: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx' //PUT ADMOB ADCODE HERE
},
android : {
banner: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx', //PUT ADMOB ADCODE HERE
interstitial: 'ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx' //PUT ADMOB ADCODE HERE
}
};
var admobid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.ios;
window.plugins.AdMob.setOptions( {
publisherId: admobid.banner,
interstitialAdId: admobid.interstitial,
adSize: window.plugins.AdMob.AD_SIZE.SMART_BANNER, //use SMART_BANNER, BANNER, IAB_MRECT, IAB_BANNER, IAB_LEADERBOARD
bannerAtTop: false, // set to true, to put banner at top
overlap: true, // banner will overlap webview
offsetTopBar: false, // set to true to avoid ios7 status bar overlap
isTesting: false, // receiving test ad
autoShow: false // auto show interstitial ad when loaded
});
registerAdEvents();
window.plugins.AdMob.createInterstitialView(); //get the interstitials ready to be shown
window.plugins.AdMob.requestInterstitialAd();
} else {
//alert( 'admob plugin not ready' );
}
}
//functions to allow you to know when ads are shown, etc.
function registerAdEvents() {
document.addEventListener('onReceiveAd', function(){});
document.addEventListener('onFailedToReceiveAd', function(data){});
document.addEventListener('onPresentAd', function(){});
document.addEventListener('onDismissAd', function(){ });
document.addEventListener('onLeaveToAd', function(){ });
document.addEventListener('onReceiveInterstitialAd', function(){ });
document.addEventListener('onPresentInterstitialAd', function(){ });
document.addEventListener('onDismissInterstitialAd', function(){
window.plugins.AdMob.createInterstitialView(); //REMOVE THESE 2 LINES IF USING AUTOSHOW
window.plugins.AdMob.requestInterstitialAd(); //get the next one ready only after the current one is closed
});
}
//display the banner
function showBannerFunc(){
window.plugins.AdMob.createBannerView();
}
//display the interstitial
function showInterstitialFunc(){
window.plugins.AdMob.showInterstitialAd();
}

Turn webcam off after "Taking Picture"

I am having an issue with turning the webcam off once I have taken a snapshot. The code below works well - but I just cant figure out how to turn off the webcam once I have everything in the canvas.
I have tried a few methods that I have found by some some research, however none seem to help.
I have tried to add video.stop(); in the "snap" eventListener, and it says "undefined is not a function", however most things I have read says it should work?
Error screenshot: https://www.dropbox.com/s/h7g4cidqhimc5ij/Screenshot%202014-08-04%2013.08.04.png
To sum it all up, when someone clicks "Take Picture", I want the picture to be taken and the camera hardware turned off. The eventlister in later half of the code below is for the "Take Picture" button.
function startCam() {
$('#can').hide();
$('#video').show();
$('#tab1-retry').hide();
$('#save-tab1').hide();
var video = document.getElementById("video"),
mask = document.getElementById("mask"),
videoObj = {
"video": true
},
errBack = function(error) {
console.log("Video capture error: ", error.code);
};
// Put video listeners into place
if (navigator.getUserMedia) { // Standard
navigator.getUserMedia(videoObj, function(stream) {
video.src = stream;
video.play();
}, errBack);
} else if (navigator.webkitGetUserMedia) { // WebKit-prefixed
navigator.webkitGetUserMedia(videoObj, function(stream) {
video.src = window.webkitURL.createObjectURL(stream);
video.play();
}, errBack);
} else if (navigator.mozGetUserMedia) { // WebKit-prefixed
navigator.mozGetUserMedia(videoObj, function(stream) {
video.src = window.URL.createObjectURL(stream);
video.play();
}, errBack);
}
document.getElementById("snap").addEventListener("click", function() {
window.canvas1 = new fabric.Canvas('canvas');
video.pause();
$('#video').hide();
$('#snap').hide();
$('#can').show();
$('#save-tab1').show();
$('#tab1-retry').show();
// VIDEO CAPTURE
var imgInstance = new fabric.Image(video, {
left: 0,
top: 0,
});
imgInstance.set('selectable', false);
canvas1.add(imgInstance);
// FIRST LAYER
mask = document.getElementById("mask");
var imgInstance1 = new fabric.Image(mask, {
left: 100,
top: 100,
cornerSize: 20
});
imgInstance1.set('selectable', true);
canvas1.add(imgInstance1);
// CANVAS LAYER
canvas1.setActiveObject(canvas1.item(1));
canvas1.item(1)['evented'] = true;
canvas1.calcOffset();
canvas1.renderAll();
});
}
inside your success callback function you could initialize the stream to a variable say:
var cameraStream = stream;
video.src = window.URL.createObjectURL(stream);
then in your 'snap' eventListener you could just pause() the video stream after taking the screenshot and close/stop the cameraStream:
video.pause();
cameraStream.stop();
.stop() closes the webcam input.

MooTools event not triggering in IE9 (only after refresh)

I changed the entire question because I didn't provide enough info's at the first run: thanks goes to #Sergio.
There are alot of things not working in IE.
When I do addEvent('domReady').... It's even more bad(it doesn't gets executed but if I refresh the page... it works).
Is there a proper way to handle that IE stuff in MooTools?
note:
working on every browser on the whole planet except IE*
edit: added the complete source code of ajax cart.
This code it correct, it's just for understanding purpose only:
ajax_cart.js
var AjaxCart = new Class({
Implements: Options,
cartDiv: null,
options: {
elem_id: 'shopping-cart-icon',
event: 'mouseenter',
url: 'changed_url_but_it's_correct='+(new Date().getTime())
},
var AjaxCart = new Class({
Implements: Options,
cartDiv: null,
options: {
elem_id: 'shopping-cart-icon',
event: 'mouseenter',
url: '/changed_url_but_it's_correct='+(new Date().getTime())
},
var AjaxCart = new Class({
Implements: Options,
cartDiv: null,
options: {
elem_id: 'shopping-cart-icon',
event: 'mouseenter',
url: '/changed_url_but_it's_correct'+(new Date().getTime())
},
initialize: function() {
var cart = this;
this.elem = $(this.options.elem_id);
if (this.elem) {
this.elem.addEvent(this.options.event, function() {
cart.viewCart();
});
}
},
getCart: function() {
var cart = this;
var myHTMLRequest = new Request.HTML({
url: cart.options.url,
onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript) {
//console.log(responseHTML);
if (!cart.cartDiv) {
cart.cartDiv = new Element('div', {'class':'ajax-cart'});
cart.cartDiv.fade('hide');
cart.cartDiv.inject(cart.elem);
cart.cartDiv.addEvent('mouseleave',function() {
this.fade('out');
});
}
cart.cartDiv.innerHTML= responseHTML;
cart.cartDiv.fade('in');
},
onFailure: function(xhr) {
console.log(xhr.responseText);
}
}).get();
},
viewCart: function() {
if (this.cartDiv) {
this.cartDiv.fade('in');
} else {
this.getCart();
}
}
});
This code works on every browser except IE, only after refreshing the page, it works.
in index.html
if(Browser.ie) {
var ajaxCart;
window.addEvent('load', function() {
ajaxCart = new AjaxCart({'elem_id':'shopping-cart-icon'});
});
} else {
var ajaxCart;
window.addEvent('load', function() {
ajaxCart = new AjaxCart({'elem_id':'shopping-cart-icon'});
});
}
In some versions of Internet Explorer (ie. IE6) a script tag might be executed twice if the content-type meta-tag declaration is put after a script tag.
The content-type should always be declared before any script tags.
See here http://mootools.net/docs/core/Utilities/DOMReady
I guess there is no solution so I had to find a workaround for this.
What I did:
Since my problems were solved by refreshing the page, I did this in meta tag.
<meta http-equiv="Expires" content="-1" />
It might help someone else, when it comes up to fixing IE refreshing bugs.