Please Help me how can i use this api correctly with the code they give in the url below
https://developers.facebook.com/docs/plugins/embedded-video-player/api/#control-reference
window.fbAsyncInit = function() {
FB.init({
appId : '17xxxxxxxxxx',
xfbml : true,
version : 'v3.5'
});
var ssp_video_player;
var time = jQuery(this).attr("time");
FB.Event.subscribe('xfbml.ready', function(msg) {
if (msg.type === 'video') {
ssp_video_player = msg.instance;
}
ssp_video_player.seek(600);
});
};
When i loading page video skip / seek works but after loading complete i did not able to control player with this variable for example
ssp_video_player.play(); or
ssp_video_player.pause(); etc.
Or any other way so i can control the facebook video player ...
The reason you are not able to control via ssp_video_player outside the function is because the variable is defined locally. You should define ssp_video_player outside the function. Also, make sure you are not accessing the play/pause before the asynchronous function is executed and the value of ssp_video_player is set.
var ssp_video_player;
window.fbAsyncInit = function() {
FB.init({
appId : '17xxxxxxxxxx',
xfbml : true,
version : 'v3.5'
});
var time = jQuery(this).attr("time");
FB.Event.subscribe('xfbml.ready', function(msg) {
if (msg.type === 'video') {
ssp_video_player = msg.instance;
}
ssp_video_player.seek(600);
});
};
Related
According to facebook documentation - https://developers.facebook.com/docs/plugins/embedded-video-player/api , we subscribe to player events
var handleDesktopEvents = function (msg) {
if (msg.type === 'video') {
var player = msg.instance;
var playHandler = player.subscribe('startedPlaying', function() {
// Video started playing ...
player.unmute();
console.log('detected video playing');
ga_virtual_pagehit(msg.id);
console.log('sent event to GA');
playHandler.removeListener('startedPlaying');
// playHandler.release();
});
console.log('detected video ready');
player.play();
FB.Event.unsubscribe('xfbml.ready', handleDesktopEvents, handleDesktopEx);
}
};
var handleDesktopEx = function () {
// Handle pause() and exceptions
console.log('detected pause');
};
FB.Event.subscribe('xfbml.ready', handleDesktopEvents, handleDesktopEx);
It seems that removeListener() is not available on the token returned by subscribe(). With a debugger, we see that there is a method release() available on the token. Should that be used? Is it now official?
Am I doing something wrong?
there was and probably still is, unless FB changed something again, a release() method. it does what removeListen() should be doing.
I just applied for Dailymotion publisher network. I have an website and i play all the Dailymotion videos using this javascript.
<script>
// This code loads the Dailymotion Javascript SDK asynchronously.
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//api.dmcdn.net/all.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s);
}());
// This function init the player once the SDK is loaded
window.dmAsyncInit = function()
{
// PARAMS is a javascript object containing parameters to pass to the player if any (eg: {autoplay: 1})
var player = DM.player("player", {video: "x27rzcj_", width: "728", height: "410", autoplay: 1});
// 4. We can attach some events on the player (using standard DOM events)
player.addEventListener("ended", function(e)
{
document.getElementById('player').style.display = 'none';
$("#videorol").fadeIn("fast");
});
};
According to Dailymotion Publisher i have to insert the syndication parameter to the iframe src. How can i achieve this by using the javascript sdk ?
Thanks
You have to pass your syndication key as a parameter of the player (query string parameter syndication=<YOUR_KEY>). This was added to the documentation https://developer.dailymotion.com/player/#player-parameters-iframe
If you want to use the sdk, you can pass this parameter as well, this is all described at https://developer.dailymotion.com/player/#player-parameters-sdk-js
for example:
var player = DM.player(document.getElementById("player"),{
video: "x7tgad0",
width: "100%",
height: "100%",
referrerPolicy: "no-referrer-when-downgrade",
params: {
'syndication': YOUR_SYNDICATION_KEY,
'ads_params' : 'YOUR_ADS_PARAMS',
'ui-logo': 'false'
}
});
I'm facing an issue when calling FB.login when page on load, the FB.login pop up is block by the browser. Currently I know I've to call FB.login after a user click event but I've to do it this way due to the business logic from client.
FB.api('/me/permissions', function(response2) {
var permsArray = response2.data[0];
var permsNeeded = ["user_events"];
var permsToPrompt = [];
for (var i in permsNeeded) {
if (permsArray[permsNeeded[i]] == null) {
permsToPrompt.push(permsNeeded[i]);
}
}
if (permsToPrompt.length > 0) {
promptForPerms(permsToPrompt);
}
});
var promptForPerms = function(perms) {
FB.login(function(response) {
}, {scope: perms.join(',')});
};
Is there any solution to call FB.login() without user click event? Or is there any tweak for this? Appreciate for the help.
You're not going to be able to code your way around the popup blocker, unfortunately.
The way to solve this is by redirecting the user to the Facebook permissions dialog when the page loads as described in the docs for manually building a login flow.
You first need to detect if the user is authenticated / connected with your application already and only redirect if they are not connected. This is best done in the window.fbAsyncInit function like this:
window.fbAsyncInit = function() {
var myAppID = 'YOUR APPLICATION ID';
FB.init({ appId: myAppID });
FB.getLoginStatus(function(response) {
if ('connected' != response.status) {
window.location.href = 'https://www.facebook.com/dialog/oauth' +
'?client_id=' + myAppID +
'&scope=user_events' +
'&redirect_uri=' + encodeURIComponent(document.URL);
} else {
alert('welcome to my app');
}
});
};
The other option is to adjust your user journey slightly; perhaps if the user is not connected then you could display an overlay with a message asking them to authenticate and a button which when clicked calls FB.login.
Anyone else no longer getting popups in Safari?
Here's some sample code that does not work in Safari. It is launched by a click on link so the popup blocker shouldn't block it. Any ideas why it does?
Online example here:
http://users.telenet.be/prullen/fbtest.html
Note that this will not run through the expected behavior since it's on another domain and has an incorrect app ID. But the only thing that matters for this example is the showing of the popup.
<script type="text/javascript">
var fbLoaded = false;
var doReLogin = true;
function createAccessToken(){
if (!fbLoaded) {
FB.init({
appId : 'xxx', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
}
fbLoaded = true;
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
getExtendedAccessToken(response.authResponse);
} else {
FB.login(function(response) {
if (response.status == 'connected') {
if (response.authResponse && response.authResponse.accessToken) {
getExtendedAccessToken(response.authResponse);
} else {
alert('You cancelled login or did not fully authorize.');
}
} else {
alert('To use you have to create an access token.');
}
}, {scope: 'read_stream'});
}
}, true);
}
function getExtendedAccessToken() {
}
</script>
<p style="text-align:center;">Connect With FaceBook</p>
Can you check your settings regarding blocking pop-up window?
This issue: Facebook Login not open in Safari/ iPhone the same as you have, I guess.
When I click on my FB log in button the FB auth dialog pops up. After I enter my FB credentials the dialog redirects to a url like this:
https://www.facebook.com/dialog/permissions.request?wholeBunchOfQueryParameters
or, if I was already logged into FB, the popup dialog is:
https://www.facebook.com/dialog/oauth?wholeBunchOfQueryParameters
but those are blank dialogs that stay open. Once I close the dialog the callback happens but not until then. This is the behavior on IE and Chrome.
I did have this working fine and I think it stopped working when I got a new computer so maybe it is environmental. I thought it has worked since then but maybe not. I reverted to a version of my code that was working and it no longer works either so that further suggests that it is environmental but I don't know what it could be. I could be off in the weeds.
Also, one other bit of info, I'm developing locally so I'm using localhost:port. I did a ton of research on this issue and did see someone say to use 127.0.0.1 instead of localhost so I did try that as well but it didn't make a difference.
Any idea why the dialogs won't close?
<fb:login-button perms="email,user_checkins" onlogin="afterFacebookConnect();"
autologoutlink="false" ></fb:login-button>
<div id="fb-root" style="display:inline; margin-left:20px;"></div>
<script language="javascript" type="text/javascript">
window.fbAsyncInit = function () {
FB.init({ appId: 'myAppId',
status: true, cookie: false, xfbml: true
});
};
function afterFacebookConnect() {
FB.getLoginStatus(function (response) {
alert("Hi");
var access_token = FB.getAuthResponse()['accessToken'];
if (response.authResponse) {
window.location = "../Account/FacebookLogin?token=" +
access_token;
} else {
alert(FB.getAuthResponse);
}
});
};
function logout() {
FB.getLoginStatus(function (response) {
var access_token = FB.getAuthResponse()['accessToken'];
if (response.authResponse) {
window.location = "../Account/Logout";
} else {
// user clicked Cancel
}
});
};
$(document).ready(function () {
if (document.getElementById('fb-root') != undefined) {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}
});
</script>
This is a known bug that has surfaced in the last few days (see https://developers.facebook.com/bugs/241915819261223).
The good news is one of FB's Engineers has just stated the following, so we should see this resolved shortly:
We have a fix for this issue and it will be pushed soon. Stay tuned.