Brightcove video templateLoadHandler not firing - javascript

well, I was struggling with the BrightCove API for the whole afternoon, and I really don't what went wrong.
I followed all Brightcove gives, and enabled the javascript api for smart player. But the templateLoadHandler is just not firing. It is really makes me crazy!
This is my code
<!doctype html>
<html>
<head>
<title>Brightcove video API demo</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="jBrightCove.js"></script>
</head>
<body>
<h2>Brightcove Video Cloud Demo</h2>
<!-- Start of Brightcove Player -->
<div style="display:none">
</div>
<!--
By use of this code snippet, I agree to the Brightcove Publisher T and C
found at https://accounts.brightcove.com/en/terms-and-conditions/.
-->
<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
<object id="myExperience1655503405001" class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="480" />
<param name="height" value="270" />
<param name="playerID" value="1655260200001" />
<param name="playerKey" value="AQ~~,AAABgXJq-HE~,N7Kwgwyc9ubOnOKgNwEM8Jm-tJbp_nzt" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="dynamicStreaming" value="true" />
<param name="#videoPlayer" value="ref:spring" />
<param name="includeAPI" value="true" />
<param name="templateLoadHandler" value="myTemplateLoaded" />
</object>
<script type="text/javascript">
// this piece of code is from BrightCove template
var player;
var modVP;
var modExp;
var modCon;
////
//
function myTemplateLoaded(experienceID) {
alert("123");
player = brightcove.api.getExperience(experienceID);
modVP = player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
modExp = player.getModule(brightcove.api.modules.APIModules.EXPERIENCE);
modCon = player.getModule(brightcove.api.modules.APIModules.CONTENT);
}
</script>
</body>
</html>
If the event is fired, then an alert would show. But never...
Anyone knows why it is not working? Thanks.

I ran your code without the jquery and jBrightcove.js includes (since I don't have them). It worked fine. If it's not working for you, I would guess there's a collision between something in the jBrightcove.js script and your code here.

Have you tried moving your handler above the HTML code? It worked for me. Plus I had to add "crossdomain.xml" file to my web server root for it to work. You might not need it but including it just in case.
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
<!-- Most restrictive policy: -->
<allow-access-from domain="admin.brightcove.com"/>
<!-- Least restrictive policy: -->
<!--
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
-->
<!--
If you host a crossdomain.xml file with allow-access-from domain="*"
and don’t understand all of the points described here, you probably
have a nasty security vulnerability. ~ simon willison
-->
</cross-domain-policy>

In this case, it seems Alex had the wrong account type. This was not the case for me. I found on a brightcove forum that the code needs to be run from a webserver. After I added the code from the site to my local XAMPP installation it worked as advertised. Here is the URL where I found the info:
http://forum.brightcove.com/t5/Media-APIs/templateLoadHandler-not-fired/td-p/19585

For late comers who have this same stubborn trouble: this is a working demo, trim it down and see what works for you.
PS, the src of the missing script within the demo should be: http://docs.brightcove.com/en/scripts/secondsToTime.js

Make sure in Brightcove you have the SmartPLayer API's enabled for each of your player types. templateLoadHandler and templateReadyHandler will not fire without this setting being changed in the Brightcove panel.

Related

Phonegap / Cordova: socialsharing plugin not working

I included the socialsharing plugin into config.xml as:
<gap:plugin name="nl.x-services.plugins.socialsharing" />
(using cordova v. 3.3.1)
In my html I include:
<script src="phonegap.js"></script>
or
<script src="cordova.js"></script>
Now when calling:
function shareReport() {
window.plugins.socialsharing.share(mytext);
}
by a button:
onclick="shareReport()"
the program stops suddenly and closes down.
("mytext" is a global variable that is populated with a text string containing html tags - this variable has a value at this point)
Any suggestions what is going wrong ?
Thank you in advance,
Chris
Social sharing Plugin will work as you expected so it looks like you missed something,
Check your XML for below fields,
<!-- for iOS -->
<feature name="SocialSharing">
<param name="ios-package" value="SocialSharing" />
</feature>
<!-- for Android -->
<feature name="SocialSharing">
<param name="android-package" value="nl.xservices.plugins.SocialSharing" />
</feature>
<!-- for Windows Phone -->
<feature name="SocialSharing">
<param name="wp-package" value="SocialSharing"/>
</feature>
AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Check your Script,
<script type="text/javascript" src="js/SocialSharing.js"></script>
This is must,
<gap:plugin name="nl.x-services.plugins.socialsharing" version="4.0" />
Try a test drive,
<button onclick="window.plugins.socialsharing.canShareVia('com.apple.social.facebook', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is facebook available on iOS?</button>
Hope this helps.
OK, I figured it out.
You were right, the SocialSharing plugin works simply by including the line
<gap:plugin name="nl.x-services.plugins.socialsharing" />
into config.xml.
My problem came from unaccepted characters in the text that I sent for sharing which caused the program crash.
Thanks for every help !

Phonegap App Won't Open External Link

Issue Solved. TIL i need to add a script link to Cordova in my html
I know the event is firing as my server shows the request to the link when I click on the button. It connects fine with chrome on my pc and tablet but the native app button won't open the system browser for me.
The link connects to a .apk download which the server is registering as requested when I press the button so the event handling is not the issue afaik. I've also tried '_blank' instead of system but still no joy
Any help would be much appreciated
Edit: Also tried navigator.app.loadUrl as per here
Edit Edit: Hmmmm, I tried inserting an ´alert("test");´ statement in the first line of the function and that's not firing... yet server of the target link is registering the requests.
The relevant patch of code is here:
Server.getUpdateInfo(getDevice()?getDevice():"Android", function (data) {
if(data.IsUpdate){
if(getDevice()){
$("#btnInstall").on("click", function(){
window.open($(this).data("url"),'_system');
});
}
else {
$("#btnInstall").closest(".ui-btn").hide();
}
}
});
Here is my config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
xmlns:android = "http://schemas.android.com/apk/res/android"
id = "com.blahblahblah"
version = "1.0.4">
<name>Server App</name>
<description>
jQuery Mobile interface for Server Admin
</description>
<author>
Firma GmbH
</author>
<access origin="*"/>
<feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<preference name="phonegap-version" value="3.1.0" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="auto-hide-splash-screen" value="true" />
<plugin name="Notification" value="org.apache.cordova.Notification"/>
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager" />
<plugin name="NetworkStatus" value="CDVConnection" />
</widget>
Ensure there's a link to the cordova script in your html file. No need to load the file yourself as phonegapp will build it.

swfobject not sending along flashvars

I am using swfobject to pass along flashvars to flash/as3, but i cannot get it to work.
The first code repent my attempt at using swfobject:
<script type="text/javascript" src="../js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {
testVar:"123"
};
swfobject.embedSWF("falsh.swf", "flashDiv", "990", "600", "10.0.0", false, flashvars);
</script>
<div id="flashDiv"></div>
The second code is my attempt to do the same thin using the tag
<object data="falsh.swf?testVar=123"
width="990" height="600" type="application/x-shockwave-flash">
<param name="quality" value="high" /></object>
For some unknown reason only the second code block successfully sends along the flashvars.
Do anyone have an idea what is wrong? Any help will be much appreciated
swfobject requires the name + id attributes to be set in order to pass the flashvars

Blackberry WebWorks SMS Listener Exception

Specs:
WebWorks 2.2, Curve 9330 OS 6 Simulator and Device
We'll, I've tried just about everything and I can't figure this out. My application has a main page (index.html) and a background page (listener.html), as specified here:
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0" rim:header="SimpleSMS">
<name>SimpleSMS</name>
<description>Simple SMS</description>
<content src="index.html">
<rim:background src="listener.html" runOnStartup="true" />
</content>
<rim:navigation mode="focus" />
<access subdomains="false" uri="http://jsconsole.com"/>
<feature id="blackberry.message.sms" />
<feature id="blackberry.app" />
<feature id="blackberry.io.dir" />
<feature id="blackberry.io.file" />
<feature id="blackberry.utils" />
</widget>
The listener.html looks like this:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="message_db2.js"></script>
<script type="text/javascript">
</script>
</head>
<body onload="initializeListener();">
</body>
</html>
The initializeListener() function is as follows:
function initializeListener() {
blackberry.message.sms.isListeningForMessage = true;
blackberry.message.sms.addReceiveListener(messageListener);
}
The issue:
When I install my app, and the listener starts running, my app can receive text messages without problems. As soon as I open the main application, the problems begin. If I just minimize the app to the background using the back or end button, the next sms received causes an exception. If I close the app through the menu, there's no exception, but the listener ceases to function. I have commented all code in messageListener and index.html does absolutely nothing but display some html. There is almost no documentation regarding having a background page. Does anyone have any ideas? Thanks in advance.
Could it be that webworks is going to these different pages and discarding everything that's in the previous page? (Like what happens to a form you fill out when you go to a new page in your browser)
Maybe you need to make use of Application Events to check when the app goes to the Foreground or Background; Maybe double check isListeningForMessage?
I'm thinking of something like
function onFG()
{
if (!blackberry.message.sms.isListeningForMessage)
{
blackberry.message.sms.isListeningForMessage = true;
blackberry.message.sms.addReceiveListener(messageListener);
}
}
blackberry.app.event.onForeground(onFG);
You can also make use of isForeground boolean if you need to have your code distinguish where it is running.

External Interface Problem: Error calling method on NPObject

Making a flash video streaming web-app using Actionscript 3's external Api. I am at a very rudimentary phase of the project where we're just experimenting with external interface. Right now i just have a flash object and 3 buttons each to play pause and load a video. The only button that is currently set up to do anything is the load button. My swf and my html file sit on the same file system, and my video files sit on another server with traffic being redirected through a media server.
When i press the load button, which should just give it the path of the video file on it's server. Instead it throws an error that reads "Error: Error Calling method on NPObject".
Without further adieu, here are snippets of relevant code:
ACTIONSCRIPT:
function loadVideo(newVideo){
clearInterval(progressInterval);
videoFile = newVideo;
stream.play(videoFile, 0, 0);
videoPositions = "0,0";
};
ExternalInterface.addCallback( "loadVideo", loadVideo );
JAVSCRIPT: (in the head of my html document)
<head>
<title> External API Test</title>
<script type="text/javascript">
var player = getFlashMovie();
if (typeof MY == 'undefined')
{
MY = {};
}
MY.load = function()
{
console.log('load called');
getFlashMovie().loadVideo("/media/preview/09/04/38833_2_720X405.mp4");
};
function getFlashMovie()
{
var isIE = navigator.appName.indexOf('Microsoft') != -1;
return (isIE) ? window['MYVID'] : document['MYVID'];
}
</script>
</head>
HTML:(in same document as javascript)
<body>
<div> This is a test</div>
<div class='my-media-player'>
<object width="720" height="405" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,16,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id='MYVID'>
<param value="as3VideoPlayer.swf" name="movie">
<param value="high" name="quality">
<param value="true" name="play">
<param value="false" name="LOOP">
<param value="transparent" name="wmode">
<param value="always" name="allowScriptAccess">
<embed width="720" height="405" name='MYVID' allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" loop="false" play="true" src="as3VideoPlayer.swf" wmode="transparent">
</object>
<div>
<button type="button" class='play'>Play</button>
<button type='button' class='pause'>Pause</button>
<button type='button' class='load' onclick='MY.load()'>Load</button>
</div>
</div>
</body>
Where is my mistake? I've read in a lot of places that this is an issue with security, but both my swf and html are in the same folder on my local machine. Only the files come from outside, and in any case I think i've set the security settings correctly when i declare my flash player in the object tag, but maybe i'm missing something there.
if you can't solve my question directly can someone please explain what "error calling method on NPObject" means? I'm sure its specific to flash-js communications because i've never seen it before and that's what i have gathered from my googling.
Thank in advanced.
I highly suggest SWFObject. Aside from that, I dare say you need to allow script access:
<script type="text/javascript">
// put your needed vars in the object below
var flashVars = {};
var params = {
allowScriptAccess:"always"
};
swfobject.embedSWF("myswf.swf", "myswf", "500", "400", "10.0.0", "", flashVars, params);
</script>
Can you try setting Security.allowDomain('*'); in your AS3 code right when it starts up?

Categories