<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>The Vose Way: Converting from Brightcove 2 and loading arbitrary videos </title>
    <link>http://www.chuckvose.com/articles/2009/09/18/converting-from-brightcove-2-and-loading-arbitrary-videos</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>A Blog about Butter, Cheese, and all things Vosian</description>
    <item>
      <title>Converting from Brightcove 2 and loading arbitrary videos </title>
      <description>&lt;p&gt;Cross-posted to: &lt;a href="http://metaltoad.com/blog/converting-brightcove-2-and-loading-arbitrary-videos"&gt;Company blog version&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Over the last two weeks I&amp;#8217;ve been working on a project to convert one of our client&amp;#8217;s websites to Brightcove 3 players. As I am quite new to drupal but not to &lt;span class="caps"&gt;PHP&lt;/span&gt; you can imagine that many of the problems I had were unrelated to brightcove itself but there were a few aspects that I thought were worth documenting for those who are in the (surprisingly) enviable position of doing this migration.&lt;/p&gt;


	&lt;p&gt;First off I want to mention how huge of an upgrade it was going between 2 and 3. It may not look like it from the player aspect, many of the players look largely the same, but the backend work was tremendous. In addition to creating a spectacular new studio for uploading media and creating playlists they redesigned the players to allow greater customization without having to build your own swf player. What&amp;#8217;s best about the backend changes is that if you really want you can actually keep your v2 players and still use the updated studio to manage your media as well as using the updated Media &lt;span class="caps"&gt;API&lt;/span&gt; to directly query their database for content to display. 
But what&amp;#8217;s been crucial for us is the new Player &lt;span class="caps"&gt;API&lt;/span&gt; which allows us to use javascript to customize the actions of the player, load videos manually, and generally cause incredible ruckus without having to recompile the player itself.&lt;/p&gt;


	&lt;p&gt;To the point though, there is one mammoth gotcha in the upgrade between v2 and v3: &lt;strong&gt;if you&amp;#8217;re specifying videos via the params (ie: almost every one of us) videos, the playlists they&amp;#8217;re in, and the player both are in, must be from the same account. &lt;/strong&gt; Additionally, &lt;strong&gt;videos must belong to the playlist that&amp;#8217;s currently loaded as well or it just will ignore your selection.&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;Before I believe it was a little loosey goosey about where things came from but now there is this hard restriction. A little arbitrary feeling but there are ways of working around it. Here&amp;#8217;s how we ended up working around the problem of having videos that didn&amp;#8217;t have a playlist or that we just wanted to load in a different order:&lt;/p&gt;


	&lt;p&gt;In order to get a list of videos into javascript quickly and easily I used drupal_to_js and let it sort out the details. This was in my module file.&lt;/p&gt;


&lt;pre&gt;
  &amp;lt;script language="JavaScript" type="text/javascript"&amp;gt;
    videos = '. drupal_to_js($videos) .';
  &amp;lt;/script&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;In our js file we create the variables we need, (remember to put var in the front or ie will flip out) and add listeners. &lt;span class="caps"&gt;TEMPLATE&lt;/span&gt;_READY will be called when the template is fully loaded and &lt;span class="caps"&gt;MEDIA&lt;/span&gt;_COLLECTION_LOAD will be called anytime there&amp;#8217;s a switch between playlists or if we use the getMediaInGroupAsynch() function.&lt;/p&gt;


&lt;pre&gt;
var player;
var video, exp, social, content;
var tabBar, videoList;

function onTemplateLoaded(pPlayer) {

  player  = bcPlayer.getPlayer(pPlayer);
  video   = player.getModule(APIModules.VIDEO_PLAYER);
  exp     = player.getModule(APIModules.EXPERIENCE);
  content = player.getModule(APIModules.CONTENT);

  exp.addEventListener(BCExperienceEvent.TEMPLATE_READY, onTemplateReady);
  if (videos != null){
    content.addEventListener(BCContentEvent.MEDIA_COLLECTION_LOAD, onMediaCollectionLoad);
  }
}
&lt;/pre&gt;

	&lt;p&gt;When the player is loaded we want to load in a new set of videos. We don&amp;#8217;t need to do anything with the return value because it will be caught by the listener we defined earlier in the js file.&lt;/p&gt;


&lt;pre&gt;
function onTemplateReady(e) {
  tabBar = exp.getElementByID("playlistTabs");
  videoList = exp.getElementByID("videoList");

  if (videos != null) {
    content.getMediaInGroupAsynch(videos);
  }
}
&lt;/pre&gt;

	&lt;p&gt;Finally we get to actually use the videos returned to the player. It&amp;#8217;s worth noting that the videos var here is exactly the same as above, a comma delimited list of video_ids. getMediaInGroupAsynch() doesn&amp;#8217;t actually do anything with the videos it loads, it just loads them in the player so that we can use them later.&lt;/p&gt;


&lt;pre&gt;
function onMediaCollectionLoad(e) {
  if (e.mediaCollection == null) {
  // Do nothing because no results came back. Must have been all disabled videos. 
  }
  else {
    //once the ids have been fetched from the service, create the runtime lineup.
    var playlist = {
      displayName: "Selected Videos",
      mediaIds: videos
    };
    var runtimeLineup = content.createRuntimeMediaCollection(playlist,"playlist");
    tabBar.insertTabAt(runtimeLineup, 0);

    // Select the new tab we created.
    tabBar.setSelectedIndex(0);

    // Select the correct video and play it.
    videoList.setSelectedIndex(0);
    video.loadVideo(list.getSelectedData());
  }
}
&lt;/pre&gt;

	&lt;p&gt;Now you may be saying to yourself, why can&amp;#8217;t I just specify a list of videos in the @videoList param? To which I have to say that I have no idea. The documentation even suggests that this is perfectly possible but in fact it isn&amp;#8217;t. In the meantime we&amp;#8217;re just going to have to learn how to use the Player &lt;span class="caps"&gt;API&lt;/span&gt;, it&amp;#8217;s probably good for us anyways. It certainly was good for me and highly entertaining!&lt;/p&gt;</description>
      <pubDate>Fri, 18 Sep 2009 18:19:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:cfbe5d16-efbc-4560-aa44-437a68d1a849</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2009/09/18/converting-from-brightcove-2-and-loading-arbitrary-videos</link>
      <category>Drupal</category>
      <category>Brightcove</category>
      <category>Programming</category>
      <category>php</category>
      <category>javascript</category>
      <category>drupal</category>
      <category>brightcove</category>
    </item>
    <item>
      <title>"Converting from Brightcove 2 and loading arbitrary videos " by christian louboutin</title>
      <description>&lt;p&gt;christian louboutinchristian louboutin&lt;/p&gt;</description>
      <pubDate>Fri, 07 Oct 2011 22:44:10 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:edd79c74-d189-4382-9b48-b3bf996768e6</guid>
      <link>http://www.chuckvose.com/articles/2009/09/18/converting-from-brightcove-2-and-loading-arbitrary-videos#comment-1653</link>
    </item>
    <item>
      <title>"Converting from Brightcove 2 and loading arbitrary videos " by moncler daunenjacke</title>
      <description>&lt;p&gt;Putting on cozy and exact moncler daunenjacke in winter is actually a sort of sharing.&lt;/p&gt;


	&lt;p&gt;We is aware, normally, moncler daunenjacke with apparel pattern and colorific form&lt;/p&gt;


	&lt;p&gt;could have an influence on our stature&amp;#8217;s luxury. As soon as we know this point, we can&lt;/p&gt;


	&lt;p&gt;easily improve apparel to hide scars, and cultivate our spirit look. We virtually can&lt;/p&gt;


	&lt;p&gt;not see an excellent stature in our genuine life, nonetheless Moncler jackets relieved&lt;/p&gt;


	&lt;p&gt;that problem at once, developing our psychological overall look. These moncler outlet&lt;/p&gt;


	&lt;p&gt;are ideal for adult males and not other jackets to produce you seems trendy. Moncler&lt;/p&gt;


	&lt;p&gt;coats will also be to be had for navy blues, greys, pink for very little women. The&lt;/p&gt;


	&lt;p&gt;designers are sensible plus they make down jackets look incredibly trendy. moncler&lt;/p&gt;


	&lt;p&gt;jacken&amp;#8217;s designer always make sure that the wearers can enjoy the nature in cold wind&lt;/p&gt;


	&lt;p&gt;with stylish design. You won&amp;#8217;t be capable of share your spiritual experiences as&lt;/p&gt;


	&lt;p&gt;readily if you you should not have on apparel that flatters you and also turn you into&lt;/p&gt;


	&lt;p&gt;seem available and appealing.&lt;/p&gt;</description>
      <pubDate>Sun, 18 Sep 2011 23:18:57 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:76440845-179e-4d6d-8351-a4bc4cdcf25c</guid>
      <link>http://www.chuckvose.com/articles/2009/09/18/converting-from-brightcove-2-and-loading-arbitrary-videos#comment-1558</link>
    </item>
    <item>
      <title>"Converting from Brightcove 2 and loading arbitrary videos " by Ed Hardy Outlet</title>
      <description>&lt;p&gt;Anything throughout lifestyle can be good luck. The good news is investigation is just not sizzling hot to end inside situations. Lifestyle themselves even now is still an effective hypnotherapist. They who may have a new precisely why to reside in could tolerate virtually any precisely how. Right here is the examination to discover no matter whether your current quest that is known is completed: should you be well, it isn&amp;#8217;t really. My spouse and i happen every day divided involving a new wish to help the entire world and also a wish to take advantage of the entire world. This specific can make it challenging for you to prepare the morning. I truly do certainly not bum out over one particular time involving my well being.&lt;/p&gt;</description>
      <pubDate>Fri, 03 Jun 2011 04:33:48 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:9ca1d09e-b147-478b-83f8-341cbd745a55</guid>
      <link>http://www.chuckvose.com/articles/2009/09/18/converting-from-brightcove-2-and-loading-arbitrary-videos#comment-981</link>
    </item>
  </channel>
</rss>

