Commit fa165f60 authored by Naoki Fukino's avatar Naoki Fukino Committed by Commit Bot

Handle BrowserBack to close the window in built-in media players.

Android apps are closed by BrowserBack key on Chrome OS.
To make the built-in app's behavior consistent and keep the app alive, we close
the built-in media players on BrowserBack.

Bug: 807521
Test: Manually tested.
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ic5097216bc83f6fd78db6f7d9155b0705b2eea3b
Reviewed-on: https://chromium-review.googlesource.com/940784Reviewed-by: default avatarTatsuhisa Yamaguchi <yamaguchi@chromium.org>
Commit-Queue: Naoki Fukino <fukino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539836}
parent 11b68126
......@@ -18,89 +18,55 @@ Polymer({
* Flag whether the audio is playing or paused. True if playing, or false
* paused.
*/
playing: {
type: Boolean,
observer: 'playingChanged',
reflectToAttribute: true
},
playing:
{type: Boolean, observer: 'playingChanged', reflectToAttribute: true},
/**
* Current elapsed time in the current music in millisecond.
*/
time: {
type: Number,
observer: 'timeChanged'
},
time: {type: Number, observer: 'timeChanged'},
/**
* Whether the shuffle button is ON.
*/
shuffle: {
type: Boolean,
notify: true
},
shuffle: {type: Boolean, notify: true},
/**
* What mode the repeat button idicates.
* repeat-modes can be "no-repeat", "repeat-all", "repeat-one".
*/
repeatMode: {
type: String,
notify: true
},
repeatMode: {type: String, notify: true},
/**
* The audio volume. 0 is silent, and 100 is maximum loud.
*/
volume: {
type: Number,
notify: true
},
volume: {type: Number, notify: true},
/**
* Whether the playlist is expanded or not.
*/
playlistExpanded: {
type: Boolean,
notify: true
},
playlistExpanded: {type: Boolean, notify: true},
/**
* Whether the artwork is expanded or not.
*/
trackInfoExpanded: {
type: Boolean,
notify: true
},
trackInfoExpanded: {type: Boolean, notify: true},
/**
* Track index of the current track.
*/
currentTrackIndex: {
type: Number,
observer: 'currentTrackIndexChanged'
},
currentTrackIndex: {type: Number, observer: 'currentTrackIndexChanged'},
/**
* URL of the current track. (exposed publicly for tests)
*/
currenttrackurl: {
type: String,
value: '',
reflectToAttribute: true
},
currenttrackurl: {type: String, value: '', reflectToAttribute: true},
/**
* The number of played tracks. (exposed publicly for tests)
*/
playcount: {
type: Number,
value: 0,
reflectToAttribute: true
},
ariaLabels: {
type: Object
}
playcount: {type: Number, value: 0, reflectToAttribute: true},
ariaLabels: {type: Object}
},
/**
......@@ -135,6 +101,13 @@ Polymer({
this.$.audio.addEventListener('loadedmetadata', onAudioStatusUpdatedBound);
},
/**
* Starts playing in inner audio element.
*/
play: function() {
this.$.audio.play();
},
/**
* Invoked when trackList.currentTrackIndex is changed.
* @param {number} newValue new value.
......
......@@ -285,7 +285,7 @@ AudioPlayer.prototype.select_ = function(newTrack) {
// Run asynchronously after an event of current track change is delivered.
setTimeout(function() {
if (!window.appReopen)
this.player_.$.audio.play();
this.player_.play();
window.appState.position = this.currentTrackIndex_;
window.appState.time = 0;
......@@ -365,6 +365,7 @@ AudioPlayer.prototype.onResize_ = function(event) {
AudioPlayer.prototype.onKeyDown_ = function(event) {
switch (util.getKeyModifiers(event) + event.key) {
case 'Ctrl-w': // Ctrl+W => Close the player.
case 'BrowserBack':
chrome.app.window.current().close();
break;
......@@ -511,7 +512,7 @@ AudioPlayer.prototype.onTrackInfoExpandedChanged_ = function(newValue) {
if (this.isTrackInfoExpanded_ !== newValue) {
this.isTrackInfoExpanded_ = newValue;
var state = chrome.app.window.current()
var state = chrome.app.window.current();
var newHeight = window.outerHeight;
if (newValue) {
state.innerBounds.minHeight = AudioPlayer.EXPANDED_MODE_MIN_HEIGHT;
......
......@@ -779,6 +779,7 @@ Gallery.prototype.onKeyDown_ = function(event) {
break;
case 'Escape':
case 'BrowserBack':
window.close();
break;
}
......
......@@ -74,6 +74,9 @@ function FullWindowVideoControls(
case 'j':
this.bigSkip(false);
break;
case 'BrowserBack':
chrome.app.window.current().close();
break;
case 'MediaStop':
// TODO: Define "Stop" behavior.
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment