ウェブサイトのビデオ埋め込みは一般的ですが、しばしば対話性が欠けています。 popcorn.jsは、埋め込まれたビデオを完全に没入感のあるエクスペリエンスに高め、動的なWebページ要素とビデオ再生を同期させます。このチュートリアルは、方法を示しています
popcorn.jsの重要な利点:
html構造:ビデオを収容するために
を作成してください:index.html
<div>popcorn.jsを含める:popcorn.jsライブラリをhtml:<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'><!DOCTYPE html>
<html>
<head>
<title>Hello World Popcorn.js</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<style>
.video, #map {
width: 300px;
height: 200px;
float: left;
}
</style>
</head>
<body>
<div class="video"></div>
</body>
</html></pre><div class="contentsignin">ログイン後にコピー</div></div>に追加します
<ol start="2">
<li>
<strong>
</strong><code><head>
JavaScript Integration(<🎜> <🎜>
app.js
高度な手法:動的コンテンツの同期:app.js
window.onload = function() { var pop = Popcorn.youtube(".video", "http://www.youtube.com/watch?v=x88Z5txBc7w"); pop.play(); };
python -m SimpleHTTPServer 2723
テキスト要素の追加:
::に国名を表示する
要素を追加します
<h2>
プラグインを使用して、特定のタイムスタンプでindex.html
コンテンツを更新してください:<h2>Yakko's singing about <span class="country-name"></span></h2>
code()
プラグイン:画像の場合はcode()
にapp.js
を追加します。 <h2>
プラグインを使用するには、// ... (previous code) ... var countries = [ { start: 20.2, end: 20.7, country_name: "United States" }, // ... add more countries ... ]; countries.forEach(function(country) { pop.code({ start: country.start, end: country.end, onStart: function() { document.querySelector(".country-name").innerHTML = country.country_name; } }); }); // ... (rest of the code) ...
flickr()
グーグルマップの統合:<div id="photos"></div>
:index.html
にGoogleマップAPIを含める
app.js
flickr()
// ... (previous code) ... countries.forEach(function(country) { // ... (code plugin) ... pop.flickr({ start: country.start, end: country.end, tags: country.country_name + " Flag", numberofimages: 5, height: "100px", width: "100px", target: "photos" }); }); // ... (rest of the code) ...
index.html<code>index.html
。 app.js<code>app.js
では、マップを初期化し、ジオコーダーを使用して国名に基づいてマーカーを配置します。
この拡張された例は、ダイナミックでインタラクティブなビデオエクスペリエンスを作成する際のpopcorn.jsの汎用性を紹介します。 詳細とプラグインのオプションについては、公式のpopcorn.jsドキュメントを参照してください。
以上がpopcorn.jsで豊富なビデオエクスペリエンスを作成しますの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。