Skip to content

Instantly share code, notes, and snippets.

View kuu's full-sized avatar

Kuu Miyazaki kuu

  • Tokyo - Japan
View GitHub Profile
// 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}`;
@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);
});
<!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 / 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') {
@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 / 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 / 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>
var sha256 = require('sha256'),
config = require('config');
function serialize(params, delimiter) {
return Object.keys(params).sort()
.map(function (key) {
return key + '=' + (params[key] !== void 0 ? params[key] : options[key]);
}).join(delimiter);
}
```js
OO.ready(function() {
var container, video;
OO.Player.create('ooyalaplayer', 'ptb2kzeToiFcfXe7n-7ufBdcYVQWupMm', {
onCreate: function (player) {
player.mb.subscribe('preloadStream', 'example', function(eventName) {
if (!video) {
return;
}

Japanese translation from the original post in English.

原文: [Getting Literal With ES6 Template Strings by Addy Osmani] (http://updates.html5rocks.com/2015/01/ES6-Template-Strings)

#ES6のテンプレート文字列

従来のJavaScriptの文字列処理はPythonやRubyに比べて非力でしたが、ES6のテンプレート文字列はこの状況を根本的に覆します。(テンプレート文字列はChrome 41からサポートされています。)それによりプログラマはドメイン固有言語(domain-specific language、DSL)を定義する事が可能になります。以下はテンプレート文字列が提供する機能です。

  • 文字列の挿入
  • 式を文字列に埋め込む