Skip to content

Commit

Permalink
Merging pr/504
Browse files Browse the repository at this point in the history
  • Loading branch information
MeoMix committed May 6, 2015
2 parents f248427 + 1183496 commit 78a6adb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions Streamus Chrome Extension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<Content Include="src\js\contentScript\interceptor.js" />
<Content Include="src\js\foreground\model\mediaSourceWrapper.js" />
<Content Include="src\js\foreground\model\sourceBufferWrapper.js" />
<Content Include="src\js\foreground\enum\keyboardKey.js" />
<Content Include="src\js\foreground\view\element\simpleMenuItemsView.js" />
<Content Include="src\js\foreground\view\leftPane\activePlaylistAreaView.js" />
<Content Include="src\js\foreground\view\leftPane\leftPaneRegion.js" />
Expand Down
3 changes: 2 additions & 1 deletion src/js/foreground/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
saveSongs: Backbone.Wreqr.radio.channel('saveSongs'),
listItem: Backbone.Wreqr.radio.channel('listItem'),
simpleMenu: Backbone.Wreqr.radio.channel('simpleMenu'),
video: Backbone.Wreqr.radio.channel('video')
video: Backbone.Wreqr.radio.channel('video'),
playPauseButton: Backbone.Wreqr.radio.channel('playPauseButton')
},

backgroundChannels: null,
Expand Down
3 changes: 3 additions & 0 deletions src/js/foreground/enum/keyboardKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define({
Space: 32
});
6 changes: 6 additions & 0 deletions src/js/foreground/view/appBar/playPauseButtonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@
initialize: function() {
this.player = Streamus.backgroundPage.player;
this.listenTo(this.player, 'change:state', this._onPlayerChangeState);

this.listenTo(Streamus.channels.playPauseButton.commands, 'tryToggle:playerState', this._tryTogglePlayerState);
},

onRender: function() {
this._setState(this.model.get('enabled'), this.player.get('state'));
},

_onClick: function() {
this._tryTogglePlayerState();
},

_tryTogglePlayerState: function(){
this.model.tryTogglePlayerState();
},

Expand Down
11 changes: 11 additions & 0 deletions src/js/foreground/view/foregroundAreaView.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
var StreamRegion = require('foreground/view/stream/streamRegion');
var SelectionBarRegion = require('foreground/view/selectionBar/selectionBarRegion');
var VideoRegion = require('foreground/view/video/videoRegion');
var KeyboardKey = require('foreground/enum/keyboardKey');
var ForegroundAreaTemplate = require('text!template/foregroundArea.html');

var ForegroundAreaView = Marionette.LayoutView.extend({
Expand Down Expand Up @@ -113,10 +114,12 @@
this._onWindowUnload = this._onWindowUnload.bind(this);
this._onWindowResize = this._onWindowResize.bind(this);
this._onWindowError = this._onWindowError.bind(this);
this._onKeyDown = this._onKeyDown.bind(this);

window.addEventListener('unload', this._onWindowUnload);
window.addEventListener('resize', this._onWindowResize);
window.addEventListener('error', this._onWindowError);
window.addEventListener('keydown', this._onKeyDown);

Streamus.backgroundPage.analyticsManager.sendPageView('/foreground.html');
},
Expand Down Expand Up @@ -171,6 +174,14 @@
Streamus.backgroundChannels.error.vent.trigger('windowError', message, url, lineNumber, columnNumber, error);
},

_onKeyDown: function (event) {
if (document.activeElement === document.body) {
if (event.keyCode == KeyboardKey.Space) {
Streamus.channels.playPauseButton.commands.trigger('tryToggle:playerState');
}
}
},

_onPlayerChangeLoading: function(model, loading) {
if (loading) {
this._startLoading();
Expand Down

0 comments on commit 78a6adb

Please sign in to comment.