Skip to content

Instantly share code, notes, and snippets.

View kuu's full-sized avatar

Kuu Miyazaki kuu

  • Tokyo - Japan
View GitHub Profile
@kuu
kuu / standalone.html
Last active April 5, 2016 07:16
Ooyala Standalone IQ demo (sending analytics signals via a vanilla HTML5 video.)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ooyala Standalone IQ demo</title>
<script src="//analytics.ooyala.com/static/analytics.js"></script>
</head>
<body>
<div>
@kuu
kuu / remote_asset.py
Last active March 30, 2016 12:04
Create a remote asset
#!/usr/bin/python
import sys
import datetime
import json
import urllib
import httplib
import hashlib
import base64
@kuu
kuu / detect-flash.html
Last active April 4, 2016 06:14
Sample code for the flash player detection.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test</title>
<script src="ua-parser.min.js"></script>
<script src="swfobject.js"></script>
<script src="//player.ooyala.com/v3/{YOUR-PLAYER-ID}"></script>
</head>
<body>
@kuu
kuu / drm-error-handling.md
Last active May 10, 2016 05:33
This is how to handle the DRM output-protection errors.
<script>
OO.ready(function() {
  OO.Player.create('container', 'content's embed_code', {
    onCreate: function (player) {
      player.mb.subscribe(
        OO.EVENTS.ERROR,
        'drm-test',
        function (event, error) {
 if (error.code === 'faxsDrmError') {
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Pause Test</title>
  <script src="//player.ooyala.com/v3/7267438d470c471eb75a165a8b670617?platform=html5-priority"></script>
</head>
<body>
  <div id="container" style="width:640px;height:360px"></div>
@kuu
kuu / smart-tv.js
Last active July 19, 2016 10:16
Demonstrates a fixed bitrate in SmartTV environment.
OO.ready(() => {
const player = OO.Player.create('container', '{embed_code}', playerParam);
if (OO.isSmartTV) {
player.mb.subscribe(OO.EVENTS.BITRATE_CHANGED, 'example', () => {
setHighestQuality(player);
});
} else {
player.mb.subscribe(OO.EVENTS.BITRATE_CHANGED, 'example', () => {
avoidHighestQuality(player);
});
// Script (requires node 6+)
const fetch = require('node-fetch');
const baseURL = 'http://player.ooyala.com';
const pcode = 'BtbmUyOlamRiH-S0S-iUeNvf_ghr';
const embedCode = 'tzNDI1NzE6gt3qQPR46SU5yi9lDEYLRJ';
const queryString = 'device=html5&domain=comment.my-demo.link';
const requestURL = `${baseURL}/sas/player_api/v1/authorization/embed_code/${pcode}/${embedCode}?${queryString}`;

Setup

Each of us runs six servers on a single local machine, so that we can show responsive demos. Below are the instructions on how to run the servers locally.

#/bin/sh
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IQ JS SDK Demo</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="//player.ooyala.com/static/v4/stable/4.10.6/core.min.js"></script>
<script src="//player.ooyala.com/static/v4/stable/4.10.6/video-plugin/main_html5.min.js"></script>
<script src="//player.ooyala.com/static/v4/stable/4.10.6/video-plugin/osmf_flash.min.js"></script>
<script src="//player.ooyala.com/static/v4/stable/4.10.6/video-plugin/bit_wrapper.min.js"></script>
const OoyalaApi = require('ooyala-api');
const api = new OoyalaApi("Your-API-Key", "Your-API-Secret");
api.get('/v2/assets', {limit: 500}, {recursive: true})
.then(list => {
return list.filter(asset => asset.asset_type === 'video');
})
.then(list => {
return Promise.all(list.map(asset => getSourceFileSize(asset.embed_code)));