2012-03-16 6 views
1

BEML에서 사용자 정의 javascript 함수를 참조 할 수있는 방법이 있습니까? 내가 한 일이 HTML5 플레이어에서도 작동해야하기 때문에 Flash에서 멀리하고 싶습니다.Brightcove에서 외부 자바 스크립트 호출 BEML

<Runtime> 
    <Layout width="800" height="600" id="backgroundTemplate"> 
    <Canvas> 
     <VideoDisplay id="videoPlayer" width="788" height="487" x="9" y="13"/> 
     <MediaControls x="5" y="509" width="791" height="87" id="mediaControls"> 
     <VBox> 
      <Canvas height="25" padding="20"> 
      <Playhead mediaController="{videoPlayer}" autohideSlider="false" useTimeToolTip="true"/> 
      </Canvas> 
      <HBox padding="10"> 
      <HBox id="leftBtn_container" hAlign="left"> 
       <ToggleButton id="playButton" width="60" height="60" x="0" y="0" showBack="true" click="{videoPlayer.play()}" toggledClick="{videoPlayer.pause()}" toggled="{videoPlayer.playing}"/> 
      </HBox> 
      <HBox id="rightBtn_container" hAlign="right"> 

       <Button width="60" height="60" id="cite_btn" click="{someFunction.doSomething()}"/> 

      </HBox> 
      </HBox> 
     </VBox> 
     </MediaControls> 
    </Canvas> 
    </Layout> 
</Runtime> 

답변

1

사용자 지정 구성 요소를 만들어야합니다. Creating Custom Player Components

BEML에서 사용자 지정 구성 요소를 호출합니다. 사용자 정의 구성 요소 BEML

<ToggleButton id="my_button" width="40" height="40" /> 

ActionScript에서

<Modules> 
     <Module file="http://urltocustomcomponent.com/my_component.swf" /> 
</Modules> 

버튼.

package 
{ 

    import com.brightcove.api.APIModules; 
    import com.brightcove.api.BrightcoveModuleWrapper 
    import com.brightcove.api.CustomModule; 
    import com.brightcove.api.modules.ExperienceModule; 
    import com.brightcove.api.events.BEMLMouseEvent; 
    import flash.events.Event; 
    import flash.external.ExternalInterface; 
    import com.brightcove.api.components.Button; 

    public class yogaComponent extends CustomModule 
    { 

     override protected function initialize():void 
     { 

      // Get the experience module 
      var experienceModule:ExperienceModule = player.getModule(APIModules.EXPERIENCE) as ExperienceModule; 

      // Define Info Button 
      var button:Button = experienceModule.getElementByID("my_button") as Button; 

      // Our listener that calls the function 
      button.addEventListener(BEMLMouseEvent.CLICK, myCustomFunc); 

     } 

     // Custom Function 
     private function myCustomFunc(event:Event):void 
     { 

      if(ExternalInterface.available) 
      { 
       // this calls a javascript function in your html 
       ExternalInterface.call('myJavascriptAlertFunction'); 
      } 
     } 

    } 
} 

이벤트 클릭시 호출되는 Javascript 기능.

function myJavascriptAlertFunction() 
{ 
alert('it works!'); 
} 
+0

감사합니다. 문제는 내가 swf를 사용할 수 없다는 것입니다. iPad에서 계속 사용할 수 있도록이 버튼이 필요합니다. – abritez

관련 문제