Skip to content

Commit 84e953c

Browse files
committed
Add cue points
1 parent 0b813b9 commit 84e953c

File tree

10 files changed

+116
-34
lines changed

10 files changed

+116
-34
lines changed

config/gulp/tasks/build.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gulp.task('build', function (done) {
1919

2020
/* Concat and minify/uglify all css, js, and copy fonts */
2121
gulp.task('build-assets', function (done) {
22-
runSequence('clean-build', ['sass', 'fonts'], function () {
22+
runSequence('clean-build', ['sass', 'fonts', 'data'], function () {
2323
gulp.src(config.app + '**/*.html', {
2424
base: config.app
2525
})
@@ -63,6 +63,14 @@ gulp.task('fonts', function () {
6363
.pipe(gulp.dest(config.build.fonts));
6464
});
6565

66+
/* Copy vtt files */
67+
gulp.task('data', function () {
68+
gulp.src(config.assets + 'data/**/*.*', {
69+
base: config.assets + 'data/'
70+
})
71+
.pipe(gulp.dest(config.build.path + '/data'));
72+
});
73+
6674
gulp.task('env', function () {
6775
return gulp.src(config.config + 'env/env.ts')
6876
.pipe(gulpTemplate({

src/app/shared/constant/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* THIS FILE IS GENERATED by `gulp env` command from `env.json`
3-
* Generated on Sun Sep 18 2016 12:01:09 GMT+0200 (CEST)
3+
* Generated on Sun Sep 18 2016 18:49:34 GMT+0200 (CEST)
44
*
55
* Make sure the keys in `env.model.ts` exist in `env.json`
66
* otherwise it'll throw message like this

src/app/vr-player.html

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
<vg-player (onPlayerReady)="onPlayerReady($event)">
2-
<vg-controls>
3-
<vg-play-pause></vg-play-pause>
2+
<div class="title" [ngClass]="{ 'hide': hideTitle }">{{ cuePointData.title }}</div>
43

5-
<vg-time-display property="current" format="mm:ss"></vg-time-display>
4+
<vg-scrub-bar style="bottom: 0;">
5+
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
6+
<vg-scrub-bar-buffering-time></vg-scrub-bar-buffering-time>
7+
<vg-scrub-bar-cue-points [cuePoints]="metadataTrack.cues"></vg-scrub-bar-cue-points>
8+
</vg-scrub-bar>
69

7-
<vg-scrub-bar>
8-
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
9-
<vg-scrub-bar-buffering-time></vg-scrub-bar-buffering-time>
10-
</vg-scrub-bar>
11-
12-
<vg-time-display property="left" format="mm:ss"></vg-time-display>
13-
14-
<vg-mute></vg-mute>
15-
16-
<vg-fullscreen></vg-fullscreen>
17-
</vg-controls>
18-
19-
<a-scene vr-mode-ui="enabled: false" (renderstart)="onAframeRenderStart()">
10+
<a-scene vr-mode-ui="enabled: true" (renderstart)="onAframeRenderStart()">
2011
<a-assets>
21-
<video [src]="currentVideo.url" vg-media id="video" preload="auto" crossorigin="anonymous" loop></video>
12+
<video [src]="currentVideo.url" vg-media id="video" preload="auto" crossorigin="anonymous" loop>
13+
<track [src]="currentVideo.track" kind="metadata" label="Cue Points" default
14+
#metadataTrack
15+
vgCuePoints
16+
(onEnterCuePoint)="onEnterCuePoint($event)"
17+
(onExitCuePoint)="onExitCuePoint($event)">
18+
</video>
2219
<img id="ringImg" src="assets/images/ring1.png" width="512" height="512">
2320
</a-assets>
2421

@@ -65,7 +62,7 @@
6562
<a-videosphere src="#video"></a-videosphere>
6663

6764
<a-camera>
68-
<a-cursor color="#2E3A87"></a-cursor>
65+
<a-cursor color="#FFFFFF"></a-cursor>
6966
</a-camera>
7067
</a-scene>
7168
</vg-player>

src/app/vr-player.ts

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ import { Component, OnInit, ElementRef } from '@angular/core';
22
import { VgFullscreenAPI, VgAPI } from 'videogular2/core';
33

44

5-
interface AframeEntity {
5+
interface IAframeEntity {
66
id: string;
77
position: string;
88
rotation: string;
99
}
10-
interface VrDoor extends AframeEntity {
10+
interface IVrDoor extends IAframeEntity {
1111
goto: string;
1212
}
13-
interface VrText extends AframeEntity {
13+
interface IVrText extends IAframeEntity {
1414
text: string;
1515
scale: string;
1616
opaAnim: string;
1717
posAnim: string;
1818
}
19-
interface VrTextPlane extends AframeEntity {
19+
interface IVrTextPlane extends IAframeEntity {
2020
position: string;
2121
rotation: string;
2222
target: string;
@@ -27,25 +27,46 @@ interface VrTextPlane extends AframeEntity {
2727
interface Video {
2828
id: string;
2929
url: string;
30-
doors: Array<VrDoor>;
31-
texts: Array<VrText>;
32-
textPlanes: Array<VrTextPlane>;
30+
track: string;
31+
doors: Array<IVrDoor>;
32+
texts: Array<IVrText>;
33+
textPlanes: Array<IVrTextPlane>;
3334
}
3435

3536
@Component({
3637
selector: 'vr-player',
37-
templateUrl: './app/vr-player.html'
38+
templateUrl: './app/vr-player.html',
39+
styles: [`
40+
.title {
41+
position: absolute;
42+
color: white;
43+
z-index: 500;
44+
font-size: 60px;
45+
background: black;
46+
padding: 10px;
47+
margin: 10px;
48+
opacity: 0.5;
49+
font-family: Helvetica, Arial, sans-serif;
50+
transition: all 0.5s ease;
51+
}
52+
.title.hide {
53+
opacity: 0;
54+
}
55+
`]
3856
})
3957
export class VRPlayer implements OnInit {
4058
elem: any;
4159
aframe: any;
60+
cuePointData: any = {};
61+
hideTitle: boolean = true;
4262
currentVideo: Video;
4363
timeout: number;
4464
vgApi:VgAPI;
4565
videos: Array<Video> = [
4666
{
4767
id: 'v0',
4868
url: 'http://static.videogular.com/assets/videos/vr-route-0.mp4',
69+
track: 'assets/data/stage-1.vtt',
4970
doors: [
5071
{id: 'd1', position: '-3 2 -10', rotation: '0 0 0', goto: 'v1'}
5172
],
@@ -55,6 +76,7 @@ export class VRPlayer implements OnInit {
5576
{
5677
id: 'v1',
5778
url: 'http://static.videogular.com/assets/videos/vr-route-1.mp4',
79+
track: 'assets/data/stage-2.vtt',
5880
doors: [
5981
{id: 'd1', position: '-15 -3 -18', rotation: '0 -180 0', goto: 'v0'},
6082
{id: 'd2', position: '8 1 9', rotation: '0 -130 0', goto: 'v2' }
@@ -77,6 +99,7 @@ export class VRPlayer implements OnInit {
7799
{
78100
id: 'v2',
79101
url: 'http://static.videogular.com/assets/videos/vr-route-2.mp4',
102+
track: 'assets/data/stage-3.vtt',
80103
doors: [
81104
{id: 'd1', position: '-1 1 -8', rotation: '0 -30 0', goto: 'v1'},
82105
{id: 'd2', position: '0 2 7', rotation: '0 180 0', goto: 'v3'}
@@ -87,6 +110,7 @@ export class VRPlayer implements OnInit {
87110
{
88111
id: 'v3',
89112
url: 'http://static.videogular.com/assets/videos/vr-route-3.mp4',
113+
track: 'assets/data/stage-4.vtt',
90114
doors: [
91115
{id: 'd1', position: '-5 2 7', rotation: '0 130 0', goto: 'v2'},
92116
{id: 'd2', position: '3 4 7', rotation: '0 210 0', goto: 'v4'}
@@ -97,6 +121,7 @@ export class VRPlayer implements OnInit {
97121
{
98122
id: 'v4',
99123
url: 'http://static.videogular.com/assets/videos/vr-route-4.mp4',
124+
track: 'assets/data/stage-5.vtt',
100125
doors: [
101126
{id: 'd1', position: '2 1 10', rotation: '0 180 0', goto: 'v3'},
102127
{id: 'd2', position: '3 2 -10', rotation: '0 180 0', goto: 'v0'}
@@ -125,7 +150,7 @@ export class VRPlayer implements OnInit {
125150

126151
ngOnInit() {
127152
this.aframe = this.elem.querySelector('a-scene');
128-
VgFullscreenAPI.onChangeFullscreen.subscribe(this.onChangeFullscreen.bind(this));
153+
//VgFullscreenAPI.onChangeFullscreen.subscribe(this.onChangeFullscreen.bind(this));
129154
}
130155

131156
onAframeRenderStart() {
@@ -158,16 +183,15 @@ export class VRPlayer implements OnInit {
158183
}
159184
}
160185

161-
onMouseEnterPlane(plane:VrTextPlane) {
186+
onMouseEnterPlane(plane:IVrTextPlane) {
162187
if (!plane.isShown) {
163188
let target = document.querySelector('#' + plane.target);
164-
console.log(plane, target);
165189
target.dispatchEvent(new CustomEvent(plane.target));
166190
plane.isShown = true;
167191
}
168192
}
169193

170-
onMouseEnter($event, door:VrDoor) {
194+
onMouseEnter($event, door:IVrDoor) {
171195
$event.target.dispatchEvent(new CustomEvent('vgStartAnimation'));
172196

173197
this.timeout = setTimeout( () => {
@@ -184,4 +208,19 @@ export class VRPlayer implements OnInit {
184208

185209
clearTimeout(this.timeout);
186210
}
211+
212+
onEnterCuePoint($event) {
213+
this.hideTitle = false;
214+
this.cuePointData = JSON.parse($event.text);
215+
}
216+
217+
onExitCuePoint($event) {
218+
this.hideTitle = true;
219+
220+
// wait transition
221+
setTimeout( () => {
222+
this.cuePointData = {};
223+
}, 500 );
224+
225+
}
187226
}

src/assets/data/stage-1.vtt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
WEBVTT FILE
2+
3+
stage-1
4+
00:00:05.200 --> 00:00:08.800
5+
{
6+
"title": "Stage 1: Altitude 1610m"
7+
}
8+

src/assets/data/stage-2.vtt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
WEBVTT FILE
2+
3+
stage-1
4+
00:00:05.200 --> 00:00:08.800
5+
{
6+
"title": "Stage 2: Altitude 1912m"
7+
}
8+

src/assets/data/stage-3.vtt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
WEBVTT FILE
2+
3+
stage-1
4+
00:00:05.200 --> 00:00:08.800
5+
{
6+
"title": "Stage 3: Altitude 2085m"
7+
}
8+

src/assets/data/stage-4.vtt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
WEBVTT FILE
2+
3+
stage-1
4+
00:00:05.200 --> 00:00:08.800
5+
{
6+
"title": "Stage 4: Altitude 2127m"
7+
}
8+

src/assets/data/stage-5.vtt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
WEBVTT FILE
2+
3+
stage-1
4+
00:00:05.200 --> 00:00:08.800
5+
{
6+
"title": "Stage 5: Altitude 2370m"
7+
}
8+

src/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
<script src="../node_modules/core-js/client/shim.min.js"></script>
2121

2222
<!-- Load libraries -->
23-
<script src="../node_modules/d3-color/build/d3-color.min.js"></script>
24-
<script src="../node_modules/d3-interpolate/build/d3-interpolate.min.js"></script>
2523
<script src="../node_modules/aframe/dist/aframe-v0.3.0.min.js"></script>
2624
<script src="../node_modules/aframe-animation-component/dist/aframe-animation-component.min.js"></script>
2725
<script src="../node_modules/aframe-bmfont-text-component/dist/aframe-bmfont-text-component.min.js"></script>

0 commit comments

Comments
 (0)