0

これが私のJavaScriptコードです

$('.vdo_player1').html("<object id='myExperience185592012001' class='BrightcoveExperience'> <param name='bgcolor' value='#FFFFFF' /><param name='width' value='624' /> <param name='height' value='330' /><param name='playerID' value='1917830444001' /><param name='playerKey' value='AQ~~,AAABrLPpvnk~,7Q4Wbq_wEtPqLNVzhMk5nzVfbE6a6vSo' /> <param name='isVid' value='true' /><param name='isUI' value='true' /> <param name='dynamicStreaming' value='true' /> <param name='@videoPlayer' value='2045929343433301' /> </object> <script type='text/javascript'>brightcove.createExperiences();</script>");

ビデオは適切に表示されていますが、ビデオがいつ終了するかを追跡し、それに基づいてStruts 2アクションクラスを呼び出す必要があります。どうすればよいですか?

4

2 に答える 2

3

Whilst user1190992's answer will work with a Flash player, it won't work with an HTML5 player as it uses the older Flash-only Player API. You should use Brightcove's Smart Player API which works with both Flash and HTML5 players.

First enable the API for the player you are using (in Video Cloud studio, player settings).

Add some additional parameters to your player code to enable the API.

<param name="includeAPI" value="true" /> 
<param name="templateLoadHandler" value="onTemplateLoaded" /> 
<param name="templateReadyHandler" value="onTemplateReady" /> 

Add javascript to set up the event listener

var player, modVP;

function onTemplateLoaded(experienceID) {
  player = brightcove.api.getExperience(experienceID);
  modVP = player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
}

function onTemplateReady(evt) {
  modVP.addEventListener(brightcove.api.events.MediaEvent.COMPLETE, onComplete);
}

function onComplete(evt) {
  alert("Video ended");
}

See also Brightcove's doc: http://support.brightcove.com/en/video-cloud/docs/listening-events-using-smart-player-api

Note: This answer and question refers to Brightcove's legacy Smart Player, this doesn't apply to the current player version

于 2013-02-06T17:05:29.700 に答える
0

Using the API, you could write a function like

<script type="text/javascript">

   var bcExp;
   var modVP;

   function onTemplateLoaded(experienceID) {
       bcExp = brightcove.getExperience(experienceID);
       modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
       modVP.addEventListener(BCMediaEvent.COMPLETE, my_function);
   }

   function my_function(event) {
       /* DO YOUR STUFF IN HERE */
   }

</script> 
于 2013-02-05T22:25:05.617 に答える