Fix #548
[KisSync.git] / src / media.js
bloba07416e217aa105cd6088084062d6ea050a66e51
1 var util = require("./utilities");
3 function Media(id, title, seconds, type, meta) {
4 if (!meta) {
5 meta = {};
8 this.id = id;
9 this.setTitle(title);
11 this.seconds = seconds === "--:--" ? 0 : parseInt(seconds);
12 this.duration = util.formatTime(seconds);
13 this.type = type;
14 this.meta = meta;
15 this.currentTime = 0;
16 this.paused = false;
19 Media.prototype = {
20 setTitle: function (title) {
21 this.title = title;
22 if (this.title.length > 100) {
23 this.title = this.title.substring(0, 97) + "...";
27 pack: function () {
28 return {
29 id: this.id,
30 title: this.title,
31 seconds: this.seconds,
32 duration: this.duration,
33 type: this.type,
34 meta: {
35 direct: this.meta.direct,
36 restricted: this.meta.restricted,
37 codec: this.meta.codec,
38 bitrate: this.meta.bitrate,
39 scuri: this.meta.scuri,
40 embed: this.meta.embed,
41 gdrive_subtitles: this.meta.gdrive_subtitles
46 getTimeUpdate: function () {
47 return {
48 currentTime: this.currentTime,
49 paused: this.paused
53 getFullUpdate: function () {
54 var packed = this.pack();
55 packed.currentTime = this.currentTime;
56 packed.paused = this.paused;
57 return packed;
60 reset: function () {
61 this.currentTime = 0;
62 this.paused = false;
66 module.exports = Media;