cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              <div class="container">
  <!-- video要素 -->
  <video id="js-video" src="https://dl.dropboxusercontent.com/u/98366439/blog/sample.mp4" preload="metadata">
  <!-- canvas要素 -->
  <canvas id="js-canvas"></canvas>

<div class="container">
  <!-- playButton要素 -->
  <button id="js-playButton">play</button>

              .container {
  width: 100%;

#js-playButton {
  width: 100%;
  height: 80px;
              // video要素
var elemVideo = document.getElementById('js-video');

// canvas要素
var elemCanvas = document.getElementById('js-canvas');

// playButton要素
var elemPlayButton = document.getElementById('js-playButton');

 * canvasの描画を実行
function canvasDraw() {
  // canvasの大きさを設定
  // video要素の大きさに合わせる
  elemCanvas.setAttribute('width', elemVideo.videoWidth);
  elemCanvas.setAttribute('height', elemVideo.videoHeight);
  // canvasのcontextを取得
  var ctx = elemCanvas.getContext('2d');

  // video要素をcanvasに描画
  ctx.drawImage(elemVideo, 0, 0, elemVideo.videoWidth,

// playButton要素にイベントを設定
window.addEventListener('load', function () {
  // onclickでcanvasの描画を実行
  elemPlayButton.addEventListener('click', canvasDraw);
  // videoのloadを実行
Loading ..................