Skip to content

Instantly share code, notes, and snippets.

@nerdyworm
Forked from pat123456/components.video-player.js
Last active January 31, 2017 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdyworm/7accff55b503501abfd466f2a5d85715 to your computer and use it in GitHub Desktop.
Save nerdyworm/7accff55b503501abfd466f2a5d85715 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
extracts: {'one_big_rabbit':[7,11], 'three_rodents':[12,14.5]},
interv: null,
actions: {
play(extractToPlay) {
let video = this.$("video")[0];
let from = this.get('extracts')[extractToPlay][0];
let to = this.get('extracts')[extractToPlay][1];
clearInterval(this.get('interv'));
video.currentTime = from;
video.play();
let _this=this;
this.set('interv', setInterval(function(){
if(video.currentTime > to){
video.pause();
clearInterval(_this.get('interv'));
}
},100))
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Player vidéo test'
});
<h1>{{appName}}</h1>
{{#video-player extractToPlay=extractToPlay as |player|}}
<button {{action (action player.play 'one_big_rabbit')}} >One big rabbit</button>
<button {{action (action player.play 'three_rodents')}} >One big rabbit</button>
{{/video-player}}
<video src="http://download.blender.org/peach/trailer/trailer_400p.ogg" width="400" ></video>
{{yield (hash play=(action 'play'))}}
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.11.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment