cms/app-client/app/services/player.js
author Chloe Laisne <chloe.laisne@gmail.com>
Fri, 05 Aug 2016 18:51:59 +0200
changeset 253 0be9770b09b4
parent 252 ba4fd614582a
child 254 a7cf2887e993
permissions -rw-r--r--
Hide/show transcript button in the player - Do not request transscript when property is null in the document request

import Ember from 'ember';

export default Ember.Service.extend(Ember.Evented, {

    items: [],
    item: null,
    model: null,
    transcript: null,

    window: '',
    playing: false,
    progress: 0, // In Milliseconds
    reduce: false,

    display: function(el) {
         if(this.get('window') !== el) {
            this.set('window', el);
        } else {
            this.set('window', '');
        }
    },

    init: function() {
        this.on('reset', Ember.run.bind(this, this.get('reset')));
    },

    setProgress: function(time) {
        this.set('progress', time);
    },

    select: function (id) {
        this.set('item', id);
    },

    play: function(id) {
        this.select(id);
        this.set('playing', true);
    },

    pause: function() {
        this.set('playing', false);
    },

    reset: function(id) {
        this.set('item', id);
    }
});