You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
266 lines
4.0 KiB
266 lines
4.0 KiB
/*jslint laxbreak:true */
|
|
/*jslint laxcomma:true */
|
|
/*jslint loopfunc:true */
|
|
/*jslint strict:true */
|
|
/*jslint browser:true */
|
|
/*jslint devel:true */
|
|
define([
|
|
"underscore"
|
|
, "jquery"
|
|
, "backbone"
|
|
|
|
, "modules/webaudio"
|
|
|
|
, "text!../../templates/player/layout.html"
|
|
, "text!../../templates/player/player-status.html"
|
|
]
|
|
, function (
|
|
_
|
|
, $
|
|
, Backbone
|
|
|
|
, WebAudio
|
|
|
|
, tmplPlayerLayout
|
|
, tmplPlayerStatus
|
|
) {
|
|
"use strict";
|
|
|
|
var Player = Backbone.View.extend({
|
|
elViewport: null
|
|
, $elViewport: null
|
|
|
|
, playIndex: []
|
|
|
|
, playCursor: 0
|
|
|
|
, webAudio: null
|
|
|
|
, _stateRandom: null
|
|
|
|
, _stateRepeat: null
|
|
|
|
, _stateMute: null
|
|
|
|
, _stateVolume: null
|
|
|
|
, _stateAudio: null
|
|
|
|
, events: {
|
|
//"click #add-friend": "showPrompt",
|
|
"click div:first-child > a.buttonPrev": "__buttonPrevious"
|
|
, "click div:first-child > a.buttonNext": "__buttonNext"
|
|
, "click div:first-child > a.buttonPlay": "__buttonPlayPause"
|
|
// Volume Down
|
|
, "click div:first-child > .playerVolumeWrapper > a:first-child": "__buttonVolumeDown"
|
|
// Volume Up
|
|
, "click div:first-child > .playerVolumeWrapper > a:last-child": "__buttonVolumeUp"
|
|
// Volume click
|
|
, "click div:first-child > .playerVolumeWrapper > input": "__buttonVolumeClick"
|
|
// Seek input
|
|
, "click div:last-child > .playerProgressWrapper > progress": "__buttonSeek"
|
|
}
|
|
|
|
, initialize: function (options) {
|
|
var that = this
|
|
;
|
|
|
|
_.bindAll(this
|
|
, "setRandomState"
|
|
, "setRepeatState"
|
|
, "__buttonPlayPause"
|
|
, "__buttonNext"
|
|
, "__buttonPrevious"
|
|
, "__buttonVolumeUp"
|
|
, "__buttonVolumeDown"
|
|
, "__buttonVolumeClick"
|
|
, "__buttonSeek"
|
|
, "_createWebAudio"
|
|
, "__waStateChanged"
|
|
, "_playerEnded"
|
|
, "_playerLoading"
|
|
, "_playNext"
|
|
, "_playPrevious"
|
|
, "_playerPause"
|
|
, "_playerStop"
|
|
, "_playerStart"
|
|
, "_setVolume"
|
|
, "_getItemData"
|
|
, "_getItemMediaUrl"
|
|
, "_setViewport"
|
|
, "_updateViewportProgress"
|
|
);
|
|
|
|
Player.__super__.initialize.apply(that);
|
|
|
|
that.$el.html(tmplPlayerLayout);
|
|
|
|
that.elViewport = document.createElement("div");
|
|
that.$elViewport = $(that.elViewport);
|
|
|
|
that.$elViewport.html(_.template(tmplPlayerStatus)({}));
|
|
|
|
that.$el.append(that.elViewport);
|
|
|
|
return that;
|
|
}
|
|
|
|
/**
|
|
* PUBLIC
|
|
**/
|
|
, setPlayIndex: function (index) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, setRandomState: function (random) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, setRepeatState: function (random) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
/**
|
|
* EVENTS
|
|
**/
|
|
, __buttonPlayPause: function (event) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, __buttonNext: function (event) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, __buttonPrevious: function (event) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, __buttonVolumeUp: function (event) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, __buttonVolumeDown: function (event) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, __buttonVolumeClick: function (event) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, __buttonSeek: function (event) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
/**
|
|
* PRIVATE
|
|
**/
|
|
// Audio Player
|
|
, _createWebAudio: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, __waStateChanged: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
// Player Controls
|
|
, _playerEnded: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _playerLoading: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _playNext: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _playPrevious: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _playerPause: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _playerStop: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _playerStart: function () {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _setVolume: function (volume) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
// Viewport methods
|
|
, _getItemData: function (item) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _getItemMediaUrl: function (item) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _setViewport: function (item) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
|
|
, _updateViewportProgress: function (progress, time) {
|
|
var that = this
|
|
;
|
|
|
|
}
|
|
});
|
|
|
|
return Player;
|
|
}); |