Last week Ooyala announced a new player, version 3, simply called "Player". Here's the announcement: videomind.ooyala.com/news/ooyala-launches-enhanced-html5-video-player-targets-mobile-devices

TL;DR: Benefits include HTML5 support on devices other than iOS (a limitation the Legacy player has) and much nicer customization options.

Legacy embed codes all still work, so existing players embedded on your site won't break. Creating a V3 embed is fairly easy:

<script src="http://player.ooyala.com/v3/<player_branding_id></script>  
<div id='playerContainer'></div>  
<script>
var myPlayer = OO.Player.create('playerContainer', '<embed_code>', {
  width: <width>, height: <height>
});
</script> 

Any chance we could get V3 Player support in? I believe you have to contact Ooyala to get the Player enabled for your account, as we've done, but that was a fairly quick affair. (Requested it last night; it was enabled by noon today.)

I'll probably be switching our site to use the new player API; I think an option in Ooyala would be great. I will try to write a patch for 6.x and 7.x in the coming weeks, if no one else gets to it first.

Comments

torgospizza’s picture

pwhstacy’s picture

torgospizza’s picture

That's a good link too.

Additionally here's a Basic V3 page: http://support.ooyala.com/developers/documentation/reference/player_v3_d... - lots of good, useful information.

makangus’s picture

Status: Active » Needs review
StatusFileSize
new2.39 KB

Attached a patch to use the V3 way to embed the player.

A few things:

  • There's a new field on the settings page for the Player Branding ID, it wouldn't work without it.
  • If you can't find the Player Branding ID in your backlot, use the scratchpad and call /v2/players to find the id
  • The additional params are in a valid javascript, but invalid JSON format, so the $params is handcrafted with only width and height support for now

There is definitely more work to do, but I am hoping at least this gives us a starting point to open a new branch for v3.

eojthebrave’s picture

Status: Needs review » Needs work
+++ b/ooyala.moduleundefined
@@ -865,10 +866,12 @@ function theme_ooyala_player($vars) {
-  return '<div id="' . $vars['params']['playerContainerId'] . '"></div><script type="text/javascript" src="http://player.ooyala.com/player.js?' . htmlspecialchars(drupal_http_build_query($vars['params'])) . '"></script>';
+  $params = '{width: ' . $vars['params']['width'] .', height: ' . $vars['params']['height'] . '}';
+
+  return '<div id="' . $vars['params']['playerContainerId'] . '"></div><script type="text/javascript"> var videoPlayer = OO.Player.create("' . $vars['params']['playerContainerId'] . '",' . '"' . $vars['embedcode'] . '", ' . $params . ');</script>';
 }
 
 /**
-- 
1.7.9.6 (Apple Git-31.1)

I think this line needs to be something like $params = json_encode($vars['params']); or drupal_json_encode().

Otherwise you're not allowing other modules to add additional paramaters to the OO.Player.create() call.

Powered by Dreditor.

makangus’s picture

That's what I had at the beginning, but Ooyala doesn't know how to read the JSON. The issue is json_encode creates {'width': '123', 'height': '123'} instead of {width: 123, height: 123}. Ooyala needs to read the second format, which is technically invalid JSON but valid JavaScript.

torgospizza’s picture

That may be an upstream issue worth bringing up to the Ooyala engineers. They've been pretty responsive in the past.

eojthebrave’s picture

I've passed the feedback about player.onCreate along to Ooyala so we'll see what happens there.

Another thing to point out is that we might want to make the entire player URL configurable not just the playerID portion of it. The reason being you can pass in additional paramaters to the URlL like ?version={{VERSION}} or ?debug=true

So maybe a textfield for 'ooyala_player_id', and one for 'ooyala_player_url'

torgospizza’s picture

Great idea. Thanks for taking the initiative!

quicksketch’s picture

StatusFileSize
new5.87 KB

I made a start at this, provided by the patch attached.

I've noticed we have numerous places depending upon the old API, i.e. ooyala_merkers module, that will need to be updated to use the new subscriber "bus" model. The new API is nicer, IMO, but currently still pretty buggy.

quicksketch’s picture

Oh, as implied by the patch, I had started to make this be a backwards compatible system for existing users who want to stick with the v2 player. Of course that means we'd need to abstract out any use of the API to use both v2 and v3 players.

quicksketch’s picture

json_encode creates {'width': '123', 'height': '123'} instead of {width: 123, height: 123}

This is only true if '123' is a string, rather than an integer data type. I'm pretty sure it gets formatted correctly assuming it the right type. We can manually set these to ensure they're correct.

torgospizza’s picture

Awesome, thanks quicksketch! I will try to test this out soon.

torgospizza’s picture

Just a couple notes, I see some violations of #1148406: Standardize embedcode / embed_code / embedCode variables where the new patch is using variations of 'embedCode' and 'embedcode' and not 'embed_code'. Perhaps that's because it's rolled against the beta and not -dev? I'm using -dev for my tests, so if you'd like I can get my working copy fixed and then roll a new patch. (The new patch might include some additional variable clean-up as I mention in my comment in that issue.

EDIT, also I'm not seeing any admin config form to set the 'ooyala_player_version' so I've added that as a textfield in ooyala.pages.inc.

Also looks like we don't have the variable 'ooyala_player_id' configured anywhere, which causes the Player JS to throw a 404; I feel like this should be a per-node-type variable as well, so that for instance, I can use different player branding IDs for "Sample" videos vs. "Purchased video" embeds.

quicksketch’s picture

Hiya @torgosPizza! Glad to know you're still following this issue.

EDIT, also I'm not seeing any admin config form to set the 'ooyala_player_version' so I've added that as a textfield in ooyala.pages.inc.

Sorry I was going to post a new reroll today. My patch is ON TOP of makangus's patch in #4.

I feel like this should be a per-node-type field as well. Maybe instead of using a variable, we make a new field available to content types?

I think you're right that more control over players is necessary. I believe it's also possible to pull the player ID from backlot on a per-video basis. It seems like that would make a lot of sense rather than asking the user what Player ID should be used at all. Or alternatively we can retrieve the list of players and let the user choose the desired player from a list. As you say this could be per-field or per-video. I'm not sure where the right balance is.

Player IDs are a bit weird. For each player you use on the site, you have to give it a separate namespace (see http://support.ooyala.com/developers/documentation/reference/player_v3_d...), which also has the effect of changing the global variables used to access some of the APIs. All of this makes me think using a single "default" player ID for now might be a good starting point to get rolling with the v3 player.

quicksketch’s picture

Sorry I was going to post a new reroll today. My patch is ON TOP of makangus's patch in #4.

Actually on further inspection my previous patch is all kinds of messed up. I'm working on a followup patch that does things correctly.

torgospizza’s picture

Thanks, I'm glad you noticed! I had some failures and so I tried doing it by hand, and then I was getting the 404s as I mentioned in the other Issue.. I finally did get the player showing up in Chrome but not Firefox! But anyway - I eagerly await your reroll. :)

Thanks!

quicksketch’s picture

Status: Needs work » Needs review
StatusFileSize
new15.57 KB

Here's a reroll that adds backwards compatibility for existing users if they need the V2 player (however currently it will switch them to V3 upon patching, maybe we should write an upgrade path?) Really appreciate your thoughts @torgosPizza!

torgospizza’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new417.4 KB

Awesome! Applied cleanly, and I am seeing player embeds on the first try. Awesome work!

Admin settings work nicely, and v2 worked just as well as v3. A notice or an upgrade path would probably be good, since it's (as of last time I checked, anyway) required that you contact Ooyala to have V3 configured on your account. Otherwise, people who apply this code might find themselves with broken Ooyala embeds until they get V3 setup.

Aside from that, I even tested the HTML5 capability on my Android browser and it worked like a charm. Delicious awesomesauce.

Excellent work as always, @quicksketch. Marking as RTBC, unless you find any issues, but those can probably go into a follow-up (along with things like "per-content type Player ID" as discussed in #15).

Here's my test node in case you're interested: http://dev.rifftrax.com/node/3323846

And attached a screenshot from my phone.

quicksketch’s picture

A notice or an upgrade path would probably be good, since it's (as of last time I checked, anyway) required that you contact Ooyala to have V3 configured on your account.

Good point, and more importantly, users *must* enter a player ID currently for the V3 player to work. Since we can't determine that automatically (afaik) we should add an upgrade path that sets the default version to V2 for existing users and leaves the default of V3 for new installs. I'll put on an upgrade hook that simply sets the variable (note this means you'll have to set your player *back* to V3 after running the upgrade).

torgospizza’s picture

That sounds like a perfect compromise. Thanks!

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed
StatusFileSize
new16.41 KB
new16.1 KB

Here's a patch that adds an upgrade hook that sets the player variable to v2 for existing installs. New installs will default to v3. Backport to D6 also attached. After testing everything functions the same as D7, I've committed the patches to the corresponding 2.x branch.

torgospizza’s picture

You rock. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.