Skip to content

Commit

Permalink
Time is a thing now
Browse files Browse the repository at this point in the history
  • Loading branch information
sxu2583 committed Nov 8, 2017
1 parent 78813ad commit 23452b9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 26 deletions.
12 changes: 11 additions & 1 deletion example/samples/dist/TextDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ var TimeAction = function () {
}, {
key: "trigger",
value: function trigger() {
console.log(this, this.args);
this.action.apply(this, this.args);
}
}]);
Expand Down Expand Up @@ -611,6 +610,17 @@ var TextDisplay = function (_Display) {
value: function handleTick() {
this.timeline.callTimeAction(this.context.time);
}
}, {
key: "recordText",
value: function recordText(time, text) {
this.timeline.addTimeAction(time, this.showText.bind(this), text);
}
}, {
key: "recordHTML",
value: function recordHTML(time, html) {
this.timeline.addTimeAction(time, this.showRichText.bind(this), html);
}

/**
* prepareTimeline is placeholder for how a TextDisplay instance loads
* time actions to it's timeline.
Expand Down
20 changes: 13 additions & 7 deletions example/samples/dist/YoutubeDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ var TimeAction = function () {
}, {
key: "trigger",
value: function trigger() {
console.log(this, this.args);
this.action.apply(this, this.args);
}
}]);
Expand Down Expand Up @@ -569,18 +568,16 @@ var YoutubeDisplay = function (_Display) {
this.player.stopVideo();
clearInterval(this.counter);
}
}, {
key: "prepareTimeline",
value: function prepareTimeline() {
console.log("Prepare Timeline");
}
}, {
key: "handleTick",
value: function handleTick() {
var th = this.timeline.treshold;
var t = this.context.time;
this.timeline.callTimeAction(this.context.time);
}

//Controll the size yourself you bums

}, {
key: "setupPlayer",
value: function setupPlayer() {
Expand All @@ -593,10 +590,19 @@ var YoutubeDisplay = function (_Display) {
}
});
}
}, {
key: "tick",
value: function tick() {
if (this.isPrimaryDisplay()) {
this.context.emitter.emit('tick');
//Replaced tick with the youtube based time
this.context.time = Math.round(this.player.getCurrentTime());
console.log(this.context.time);
}
}
}, {
key: "setup",
value: function setup() {
this.prepareTimeline();
this.firstScriptTag = document.getElementsByTagName('script')[0];
this.firstScriptTag.parentNode.insertBefore(this.script_tag, this.firstScriptTag);
window.onYouTubeIframeAPIReady = this.setupPlayer.bind(this);
Expand Down
12 changes: 12 additions & 0 deletions example/samples/text_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ class TextDisplay extends Display {
handleTick() {
this.timeline.callTimeAction(this.context.time);
}



recordText(time, text) {
this.timeline.addTimeAction(time, this.showText.bind(this), text);

}
recordHTML(time, html) {
this.timeline.addTimeAction(time, this.showRichText.bind(this), html);
}


/**
* prepareTimeline is placeholder for how a TextDisplay instance loads
* time actions to it's timeline.
Expand Down
16 changes: 10 additions & 6 deletions example/samples/youtube_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ class YoutubeDisplay extends Display {
clearInterval(this.counter);
}

prepareTimeline(){
console.log("Prepare Timeline");
}

handleTick(){
var th = this.timeline.treshold;
var t = this.context.time;
this.timeline.callTimeAction(this.context.time);
}

//Controll the size yourself you bums
setupPlayer(){
this.player = new YT.Player(this.player_id, {
height: '390',
Expand All @@ -43,8 +40,16 @@ class YoutubeDisplay extends Display {
});
}

tick() {
if (this.isPrimaryDisplay()) {
this.context.emitter.emit('tick');
//Replaced tick with the youtube based time
this.context.time = Math.round(this.player.getCurrentTime());
console.log(this.context.time);
}
}

setup(){
this.prepareTimeline();
this.firstScriptTag = document.getElementsByTagName('script')[0];
this.firstScriptTag.parentNode.insertBefore(this.script_tag, this.firstScriptTag);
window.onYouTubeIframeAPIReady = this.setupPlayer.bind(this);
Expand All @@ -58,7 +63,6 @@ class YoutubeDisplay extends Display {
this.player.playVideo();
this.counter = setInterval(this.tick.bind(this), this.t_ratio);
}

};

module.exports = YoutubeDisplay;
18 changes: 7 additions & 11 deletions example/video_coordinated.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,19 @@ <h4>DisplayCoordinator example</h4>
canvas_class: "sideView"});

var htmlTest =

'<div class="test">' +
'<a href="https://en.wikipedia.org/wiki/%22Hello,_World!%22_program">"Hello, World!" program - Wikipedia</a>' +
'</div>'


td.prepareTimeline = function() {
this.timeline.addTimeAction(4, this.showRichText.bind(this), htmlTest);
this.timeline.addTimeAction(10, this.showRichText.bind(this), '<a href="https://www.python.org/">Welcome to Python.org</a></h4><p>The official home of the Python Programming Language</p>');
this.timeline.addTimeAction(12, this.showRichText.bind(this), '<a href="https://www.howtogeek.com/140679/beginner-geek-how-to-start-using-the-linux-terminal/">How to user Linux Terminal</a><br /><a href="http://www.computerhope.com/issues/chusedos.htm">How to use CMD</a>');
this.timeline.addTimeAction(18, this.showRichText.bind(this), '<a href="https://www.python.org/downloads/">Download Python</a></h4><p>The official home of the Python Programming Language</p>');
this.timeline.addTimeAction(30, this.showRichText.bind(this), '<a href="https://en.wikipedia.org/wiki/Vim_(text_editor)">Vim (text editor) - Wikipedia</a></h4><p>Vim (; a contraction of Vi IMproved) is a clone of Bill Joy\'s vi text editor program for Unix. It was written by Bram Moolenaar based on source for a port of the Stevie editor to the Amiga and first released publicly in 1991.</p>');
this.timeline.addTimeAction(41, this.showRichText.bind(this), '<a href="https://www.python.org/doc/">Python Docs</a>');
}

td.recordHTML(4, htmlTest);
td.recordHTML(10, '<a href="https://www.python.org/">Welcome to Python.org</a></h4><p>The official home of the Python Programming Language</p>');
td.recordHTML(12, '<a href="https://www.howtogeek.com/140679/beginner-geek-how-to-start-using-the-linux-terminal/">How to user Linux Terminal</a><br /><a href="http://www.computerhope.com/issues/chusedos.htm">How to use CMD</a>');
td.recordHTML(18, '<a href="https://www.python.org/downloads/">Download Python</a></h4><p>The official home of the Python Programming Language</p>');
td.recordHTML(30, '<a href="https://en.wikipedia.org/wiki/Vim_(text_editor)">Vim (text editor) - Wikipedia</a></h4><p>Vim (; a contraction of Vi IMproved) is a clone of Bill Joy\'s vi text editor program for Unix. It was written by Bram Moolenaar based on source for a port of the Stevie editor to the Amiga and first released publicly in 1991.</p>');
td.recordHTML(41, '<a href="https://www.python.org/doc/">Python Docs</a>');
td.setAsReady();


var DisplayCoordinator = Displays.DisplayCoordinator;
var lesson_coordinator = new DisplayCoordinator({
stage: {
Expand Down
1 change: 0 additions & 1 deletion src/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class TimeAction {
* Trigger an action by calling *func* and passing it *args* passed from initialization.
*/
trigger(){
console.log(this, this.args);
this.action.apply(this, this.args);
}
};
Expand Down

0 comments on commit 23452b9

Please sign in to comment.