2014-05-21 02:30:14 +00:00
|
|
|
var util = require("./utilities");
|
2014-02-03 02:04:50 +00:00
|
|
|
|
2014-05-21 02:30:14 +00:00
|
|
|
function Media(id, title, seconds, type, meta) {
|
|
|
|
if (!meta) {
|
|
|
|
meta = {};
|
|
|
|
}
|
2013-04-24 19:28:20 +00:00
|
|
|
|
2013-02-16 05:02:42 +00:00
|
|
|
this.id = id;
|
2014-06-04 04:21:00 +00:00
|
|
|
this.setTitle(title);
|
2014-02-03 02:04:50 +00:00
|
|
|
|
2014-05-21 02:30:14 +00:00
|
|
|
this.seconds = seconds === "--:--" ? 0 : parseInt(seconds);
|
|
|
|
this.duration = util.formatTime(seconds);
|
|
|
|
this.type = type;
|
|
|
|
this.meta = meta;
|
|
|
|
this.currentTime = 0;
|
|
|
|
this.paused = false;
|
2013-02-16 05:02:42 +00:00
|
|
|
}
|
|
|
|
|
2014-05-21 02:30:14 +00:00
|
|
|
Media.prototype = {
|
2014-06-04 04:21:00 +00:00
|
|
|
setTitle: function (title) {
|
|
|
|
this.title = title;
|
|
|
|
if (this.title.length > 100) {
|
|
|
|
this.title = this.title.substring(0, 97) + "...";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-05-21 02:30:14 +00:00
|
|
|
pack: function () {
|
|
|
|
return {
|
|
|
|
id: this.id,
|
|
|
|
title: this.title,
|
|
|
|
seconds: this.seconds,
|
|
|
|
duration: this.duration,
|
|
|
|
type: this.type,
|
|
|
|
meta: {
|
|
|
|
direct: this.meta.direct,
|
2014-06-01 18:43:18 +00:00
|
|
|
restricted: this.meta.restricted,
|
|
|
|
codec: this.meta.codec,
|
2015-01-11 18:10:09 +00:00
|
|
|
bitrate: this.meta.bitrate,
|
2015-06-18 22:46:33 +00:00
|
|
|
scuri: this.meta.scuri,
|
2015-07-25 08:19:32 +00:00
|
|
|
embed: this.meta.embed,
|
|
|
|
gdrive_subtitles: this.meta.gdrive_subtitles
|
2014-05-21 02:30:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
getTimeUpdate: function () {
|
|
|
|
return {
|
|
|
|
currentTime: this.currentTime,
|
|
|
|
paused: this.paused
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
getFullUpdate: function () {
|
|
|
|
var packed = this.pack();
|
|
|
|
packed.currentTime = this.currentTime;
|
|
|
|
packed.paused = this.paused;
|
|
|
|
return packed;
|
|
|
|
},
|
|
|
|
|
|
|
|
reset: function () {
|
|
|
|
this.currentTime = 0;
|
|
|
|
this.paused = false;
|
2014-02-03 02:04:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-05-21 02:30:14 +00:00
|
|
|
module.exports = Media;
|