Note that there are some explanatory texts on larger screens.

plurals
  1. POOoyala AS3 API strange issue
    text
    copied!<p>I have got a strange issue with Ooyala AS3 API. </p> <p>Below code works perfect, I have got a requirement to remove adSetCode so when I remove <code>params['adSetCode'] = param.adSetCode;</code> from <code>ExternalInterface.addCallback</code> function and call </p> <pre><code>$("#player-id")[0].setQueryStringParameters({embedCode:id,links:url,autoplay:'1',adSetCode:asc, keywords:keys}); </code></pre> <p>it works but only once. I can see the values being updated but video gets updated only first time?</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:ooyala="com.ooyala.api.*"&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.core.FlexGlobals; [Bindable] public var embedCode:String = 'FqcWJ4Mjpnzw0ZNH6aGE-CE6ZPKZReZp'; [Bindable] public var adSetCode:String = 's2MzU6rIBpTe20SzgA_OahnRJMNZf_zJ'; [Bindable] public var playerID:String = ''; public var autoPlay:String = "false"; public var keywords:String = ''; //inSkin keywords public var params:Object = new Object(); override protected function initializationComplete():void { super.initializationComplete(); if(FlexGlobals.topLevelApplication.parameters.embedCode != undefined) { embedCode = FlexGlobals.topLevelApplication.parameters.embedCode; } if(FlexGlobals.topLevelApplication.parameters.adSetCode != undefined) { adSetCode = FlexGlobals.topLevelApplication.parameters.adSetCode; } if(FlexGlobals.topLevelApplication.parameters.keywords != undefined) { keywords = FlexGlobals.topLevelApplication.parameters.keywords; } if(FlexGlobals.topLevelApplication.parameters.autoplay != undefined) { autoPlay = FlexGlobals.topLevelApplication.parameters.autoplay; } player.load(); ExternalInterface.addCallback("setQueryStringParameters", function(param:Object):void { params['embedCode'] = param.embedCode; params['adSetCode'] = param.adSetCode; params['autoplay'] = param.autoplay; keywords = param.keywords; player.queryStringParameters = params; }) player.addEventListener("apiReady",function(event:Event):void { main(); }); } public function main():void { if(autoPlay == "true") { player.playMovie(); } var jsStr:String = player.embedCode+'^'+player.title; keywords = removeNonNumericChars(keywords); //Add event listeners here for js player.addEventListener("stateChanged", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, player.state ); } catch(e:ErrorEvent) {} // just throwing this away as the function may or may not be there. }); player.addEventListener("playheadTimeChanged", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, player.state ); } catch(e:ErrorEvent) {} }); player.addEventListener("playComplete", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, player.state ); } catch(e:ErrorEvent) {} }); player.addEventListener("adStarted", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, player.state ); } catch(e:ErrorEvent) {} }); player.addEventListener("adCompleted", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, player.state ); } catch(e:ErrorEvent) {} }); player.addEventListener("embedCodeChanged", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, jsStr ); } catch(e:ErrorEvent) {} }); //Send play started event for tealium tracking on main try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, 'PlayStarted', jsStr ); ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, 'inSkinKeywords', keywords ); } catch(e:ErrorEvent) {} // just throwing this away as the function may or may not be there. //Following events are for inskin implementation player.addEventListener("apiReady", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, '' ); } catch(e:ErrorEvent) {} }); player.addEventListener("currentItemEmbedCodeChanged", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, jsStr + '^' + player.description + '^' + player.totalTime + '^' + player.lineup ); } catch(e:ErrorEvent) {} }); player.addEventListener("fullscreenChanged", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, player.fullscreen ); } catch(e:ErrorEvent) {} }); player.addEventListener("totalTimeChanged", function(event:Event):void { try { ExternalInterface.call("receiveOoyalaEvent", FlexGlobals.topLevelApplication.parameters.id, event.type, player.totalTime ); } catch(e:ErrorEvent) {} }); //Methods for inskin implementation ExternalInterface.addCallback("inSkinPlay",Play); ExternalInterface.addCallback("inSkinPause",Pause); ExternalInterface.addCallback("getTotalTime",getTotalTime); ExternalInterface.addCallback("getInSkinKeywords",getInSkinKeywords); } private function Play():void { player.playMovie(); } private function Pause():void { player.pauseMovie(); } private function getTotalTime():Number { return player.totalTime; } private function getInSkinKeywords():String { return keywords; } private function removeNonNumericChars($str:String):String { $str = $str.toLowerCase(); $str = replaceAll($str, " ", "-") var newStr:String = ""; for (var i:int = 0; i&lt;$str.length; i++) { var currentCharCode:Number = $str.charCodeAt(i); if ((currentCharCode &gt;= 48) &amp;&amp; (currentCharCode &lt;= 57) || (currentCharCode &gt;= 97) &amp;&amp; (currentCharCode &lt;= 122) || (currentCharCode == 45) || (currentCharCode == 44)) { newStr += $str.charAt(i); } } return newStr; } private function replaceAll(str:String, fnd:String, rpl:String):String{ return str.split(fnd).join(rpl); } ]]&gt; &lt;/fx:Script&gt; &lt;fx:Declarations&gt; &lt;fx:Object id = "defaultPlayerSettings" allowFullScreen = "true" autoplay = "false" embedCode = "{embedCode}" adSetCode = "{adSetCode}" /&gt; &lt;/fx:Declarations&gt; &lt;ooyala:Player id="player" width="100%" height="100%" verticalCenter="0" horizontalCenter="0" queryStringParameters="{defaultPlayerSettings}" /&gt; &lt;/s:Application&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload