Skip to content

Commit

Permalink
demo: add m3u8 HLS video demo
Browse files Browse the repository at this point in the history
* docs: add m3u8 hls demo

* docs: replace demo thumb & descriptions
  • Loading branch information
WoodNeck authored Sep 7, 2021
1 parent 57b4980 commit 5769f82
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 3 deletions.
5 changes: 5 additions & 0 deletions demo/_data/egjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ subComponents:
description: View partial panorama image by setting yawRange, pitchRange, fovRange
link: examples/panoviewer/etc/partial_panorama.html
sort: 15
- name: m3u8 HLS video
image: panoviewer/hls.png
description: Play .m3u8 HLS video with hls.js
link: examples/panoviewer/etc/hls.html
sort: 16
- name: Cubemap
id: cubemap
image: cubemap.jpg
Expand Down
Binary file added demo/common/img/panoviewer/hls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions demo/examples/img/m3u8/equi.m3u8
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.000000,
equi0.ts
#EXTINF:10.000000,
equi1.ts
#EXTINF:10.000000,
equi2.ts
#EXTINF:10.000000,
equi3.ts
#EXTINF:10.000000,
equi4.ts
#EXTINF:10.000000,
equi5.ts
#EXTINF:10.000000,
equi6.ts
#EXTINF:10.000000,
equi7.ts
#EXTINF:6.360000,
equi8.ts
#EXT-X-ENDLIST
Binary file added demo/examples/img/m3u8/equi0.ts
Binary file not shown.
Binary file added demo/examples/img/m3u8/equi1.ts
Binary file not shown.
Binary file added demo/examples/img/m3u8/equi2.ts
Binary file not shown.
Binary file added demo/examples/img/m3u8/equi3.ts
Binary file not shown.
Binary file added demo/examples/img/m3u8/equi4.ts
Binary file not shown.
Binary file added demo/examples/img/m3u8/equi5.ts
Binary file not shown.
Binary file added demo/examples/img/m3u8/equi6.ts
Binary file not shown.
Binary file added demo/examples/img/m3u8/equi7.ts
Binary file not shown.
Binary file added demo/examples/img/m3u8/equi8.ts
Binary file not shown.
138 changes: 138 additions & 0 deletions demo/examples/panoviewer/etc/hls.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<title>eg.view360 examples HLS</title>
<link rel="stylesheet" type="text/css" href="../../../common/css/demo.css">
<link rel="stylesheet" type="text/css" href="../../../common/css/PanoControls.css">

<script src="../../../common/js/jquery-2.2.4.js"></script>
<script src="../../../common/js/codepen.js"></script>
<script src="../../../common/js/qrcode.js"></script>
<script src="../../../common/js/screenfull.min.js"></script>
<script src="../../../common/js/PieView.js"></script>
<script src="../../../release/latest/dist/view360.pkgd.js"></script>
<script src="../../../common/js/PanoControls.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/webxr-polyfill@latest/build/webxr-polyfill.min.js"></script>
<script src="../../../common/js/initXR.js"></script>
</head>

<body>
<div class="qrcode"></div>
<header>
<div class="home">
<a href="../../../panoviewer.html">
<img class="egjs_logo" src="./../../../common/img/type_black.svg">
PanoViewer
</a>
</div>
<h1>m3u8 HLS video</h1>
</header>
<h2>Play m3u8 HLS 360 video with PanoViewer, with <a href="https://github.com/video-dev/hls.js/" target="_blank">hls.js</a></h2>
<div class="infos">
<p class="info">
<span class="head">projection</span>: <a href="https://naver.github.io/egjs-view360/release/latest/doc/eg.view360.PanoViewer.PROJECTION_TYPE.html" target="_blank"><span class="value">STEREOSCOPIC_EQUI</span></a>
</p>
<p class="info">
<span class="head">video</span>: <a href="../../img/m3u8/equi.m3u8" target="_blank"><span class="value">Visions - Burano in VR by Maja Wrońska (https://vimeo.com/244870931)</span></a>
</p>
</div>
<div class="viewer">
<video id="video" playsinline="playsinline" controls loop preload="auto" crossorigin="anonymous"></video>
<div class="container"></div>
<div class="play-container">
<button class="play"></button>
</div>
</div>
<div class="source">
<pre>
var videoUrl = "../../img/m3u8/equi.m3u8";
var PanoViewer = eg.view360.PanoViewer;
var panoviewer = document.querySelector(".viewer");
var container = document.querySelector(".viewer .container");
var video = document.getElementById("video");
var btn = document.getElementById("play");

if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(videoUrl);
hls.attachMedia(video);
} else if (video.canPlayType("application/vnd.apple.mpegurl")) {
video.src = videoUrl;
}

video.addEventListener("play", () => {
var PanoViewer = eg.view360.PanoViewer;
var container = document.querySelector(".container");
var viewer = new PanoViewer(container, {
video: video,
projectionType: "equirectangular"
});

window.addEventListener("resize", function () {
panoViewer.updateViewportDimensions();
});

document.querySelector(".play-container").style.display = "none";

window.addEventListener("resize", function (e) {
viewer.updateViewportDimensions();
});

PanoControls.init(panoviewer, viewer);
PanoControls.showLoading();
});

document.querySelector(".play-container .play").addEventListener("click", function () {
video.play();
});
</pre>
</div>
</body>
<script>
var videoUrl = "../../img/m3u8/equi.m3u8";
var PanoViewer = eg.view360.PanoViewer;
var panoviewer = document.querySelector(".viewer");
var container = document.querySelector(".viewer .container");
var video = document.getElementById("video");
var btn = document.getElementById("play");

if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(videoUrl);
hls.attachMedia(video);
} else if (video.canPlayType("application/vnd.apple.mpegurl")) {
video.src = videoUrl;
}

video.addEventListener("play", () => {
var PanoViewer = eg.view360.PanoViewer;
var container = document.querySelector(".container");
var viewer = new PanoViewer(container, {
video: video,
projectionType: "equirectangular"
});

window.addEventListener("resize", function () {
panoViewer.updateViewportDimensions();
});

document.querySelector(".play-container").style.display = "none";

window.addEventListener("resize", function (e) {
viewer.updateViewportDimensions();
});

PanoControls.init(panoviewer, viewer);
PanoControls.showLoading();
});

document.querySelector(".play-container .play").addEventListener("click", function () {
video.play();
});
</script>
</html>
2 changes: 1 addition & 1 deletion demo/panoviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ subComponentName: PanoViewer
demo: _includes/panoviewer/panoviewer_demo.html
features: _includes/panoviewer/panoviewer_features.md
started: _includes/panoviewer/panoviewer_started.md
---
---
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"es2015": "dist/view360.esm.js",
"types": "declaration/index.d.ts",
"scripts": {
"start": "webpack-dev-server --open --host 0.0.0.0",
"start": "rollup -c ./rollup.config.dev.js -w",
"build": "rm -rf ./dist && rollup -c && npm run declaration && npm run printsizes",
"watch": "rollup -c -w",
"declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
"printsizes": "print-sizes ./dist --exclude=\\.map",
"test": "karma start",
Expand Down
17 changes: 17 additions & 0 deletions rollup.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import buildHelper from "@egjs/build-helper";

const name = "eg.view360";
const plugins = [];

export default buildHelper([
{
name,
input: "./src/index.umd.ts",
output: "./dist/view360.pkgd.js",
format: "umd",
commonjs: true,
resolve: true,
plugins
}
]);

0 comments on commit 5769f82

Please sign in to comment.