javascriptvideobrightcove

Brightcove videos embed using javascript API


I am trying to use the javascript API for embedding the videos using video id. After several trail, I found the way to do it and I want to make sure whether this is the right way to use it or is there anything I am missing?

This code is working fine but need to know if I am doing it in wrong way.

 <script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>

    <object class="BrightcoveExperience">
        <param name="bgcolor" value="#FFFFFF" />
        <param name="width" value="480" />
        <param name="height" value="270" />
        <param name="playerID" value="4942277584001" />
        <param name="playerKey" value="AQ~~,AAAEfriyQEE~,ZL37ulQzt-toqcwK_Cwr35Bl9P3znlYu" />
        <param name="isVid" value="true" />
        <param name="isUI" value="true" />
        <param name="dynamicStreaming" value="true" />
        <param name="@videoPlayer" value="5072209967002" />   
    </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>
<script type="text/JavaScript">
    var player,
    APIModules,
    videoPlayer;
    function onTemplateLoad(experienceID){
     player = brightcove.api.getExperience(experienceID);
     APIModules = brightcove.api.modules.APIModules;
    }
    function onTemplateReady(evt){
     videoPlayer = player.getModule(APIModules.VIDEO_PLAYER);
     videoPlayer.play();
    }
</script>
<!-- End of Brightcove Player -->

Solution

  • Brightcove player is used to play the brightcove videos. The code written by you is correct but it is shown in brightcove docs that it uses legacy player. The recommended/current way of using the brightcove with embed code as specified in http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/embed-in-page.html is :

    <video data-video-id="4784463159001"
            data-account="1507807800001"
            data-player="SkSyF9Cl"
            data-embed="default"
            class="video-js"
            controls></video>
    <script src="//players.brightcove.net/1507807800001/SkSyF9Cl_default/index.min.js"></script>
    

    where video id is specified in data-video-id attribute and account id in data-account and player details in data-player attribute.

    For more info on how to use embed code with javascript you could go through the above link specified.

    NOTE: Also replace the script src link with your account id and player key details.

    Hope it helps.