嵌入代码Brightcove media api

时间:2013-02-15 16:26:25

标签: api html publish brightcove

我正试图通过brightcove找到一种方法来访问我的媒体API上的视频发布代码,就像你可以在云工作室那样为下面这样的播放器获取的那个。

<!-- 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="myExperience" class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="960" />
<param name="height" value="445" />
<param name="playerID" value="2164048951001" />
<param name="playerKey" value="AQ~~,AAABzJDWv4k~,nrw5-YJoyhvZYIpODobX62cNFZVSM1ri" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="dynamicStreaming" value="true" />

</object>

<!-- 
This script tag will cause the Brightcove Players defined above it to be created as soon
as the line is read by the browser. If you wish to have the player instantiated only after
the rest of the HTML is processed and the page load is complete, remove the line.
-->
<script type="text/javascript">brightcove.createExperiences();</script>

我想在我的api的视频元数据部分中选择这个,有没有人有任何建议从哪里开始。感谢。

1 个答案:

答案 0 :(得分:3)

我不确定您是否可以通过BC API收集资产的发布代码,但这不是必需的。您可以做的是使用变量来替换可能更改的片段中的唯一项目 - 主要是playerID和playerKey以及videoPlayer值(这将指示要使用哪个播放器以及要插入的视频),还有可能的宽度和高度设置。

假设您正在寻找动态换掉视频(假设您将始终使用相同的播放器),您可以执行以下操作:

function get_player($video_id){
$player = '<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>    
<object id="myExperience" class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="960" />
<param name="height" value="445" />
<param name="playerID" value="2164048951001" />
<param name="playerKey" value="AQ~~,AAABzJDWv4k~,nrw5-YJoyhvZYIpODobX62cNFZVSM1ri" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="dynamicStreaming" value="true" />
<param name="@videoPlayer" value="'.$video_id.'" />
</object><script type="text/javascript">brightcove.createExperiences();</script>';
return $player;
}

然后使用您要在此播放器中显示的视频的ID调用该函数。同样可以应用于交换球员和大小。

echo get_player('my_video_id');
@videoPlayer param告诉玩家要加载哪个视频。 这documentation可能会有所帮助。