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 Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

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 ..................