Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1055198 - [Video] Hide soft home key during full screen video pla…
Browse files Browse the repository at this point in the history
…yback
  • Loading branch information
Russ Nicoletti committed Sep 26, 2014
1 parent a884412 commit eba8538
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 6 deletions.
3 changes: 3 additions & 0 deletions apps/video/index.html
Expand Up @@ -10,6 +10,9 @@
<!-- this file is loaded lazily but is listed here so it gets packaged
<link rel="stylesheet" href="shared/style/confirm.css" type="text/css" />
-->
<!-- this file is loaded lazily but is listed here so it gets packaged
<link rel="stylesheet" href="style/confirm.css" type="text/css" />
-->
<link rel="stylesheet" type="text/css" href="style/video.css" />
<link rel="stylesheet" type="text/css" href="style/info.css" />
<link rel="stylesheet" type="text/css" href="style/spinner.css" />
Expand Down
47 changes: 41 additions & 6 deletions apps/video/js/video.js
Expand Up @@ -215,9 +215,21 @@ function initLayout() {
dom.playerView.classList.add('disabled');
}

// We handle the isPortrait calculation here, because window dispatches
// multiple resize event with different width and height in Firefox nightly.
window.addEventListener('screenlayoutchange', handleScreenLayoutChange);
//
// Regarding how we handle screen orientation changes, we can use either
// 'screenlayoutchange' or 'resize' events. Both have negative side affects:
//
// 'resize' -- firefox nightly dispatches multiple 'resize' events with
// different width and height when using the rotate button in
// the responsive design view.
// 'screenlayoutchange' -- causes a problem when hiding the software home
// button using mozRequestFullScreen due to the
// timing of the layout change event and the
// MediaQueryList events (bug 1062022).
//

//window.addEventListener('screenlayoutchange', handleScreenLayoutChange);
window.onresize = handleScreenLayoutChange;

switchLayout(LAYOUT_MODE.list);
}
Expand Down Expand Up @@ -283,6 +295,23 @@ function toggleFullscreenPlayer(e) {
currentVideo.metadata.rotation || 0);
}

document.addEventListener('mozfullscreenerror', function fullScreenError(e) {
console.error('mozfullscreenerror -- ' + e);
});

function setSoftwareHomeButtonVisibility(visible) {
// Currently we only support when the device has no hardware home button
if (!ScreenLayout.getCurrentLayout('hardwareHomeButton')) {
if (visible) {
document.mozCancelFullScreen();
dom.videoControls.classList.add('software-button-present');
}
else {
dom.playerView.mozRequestFullScreen();
}
}
}

function toggleVideoControls(e) {
// When we change the visibility state of video controls, we need to check the
// timeout of auto hiding.
Expand All @@ -297,9 +326,11 @@ function toggleVideoControls(e) {
// If control not shown, tap any place to show it.
setControlsVisibility(true);
e.cancelBubble = true;
setSoftwareHomeButtonVisibility(true);
} else if (e.originalTarget === dom.videoControls) {
// If control is shown, only tap the empty area should show it.
setControlsVisibility(false);
setSoftwareHomeButtonVisibility(false);
}
}
}
Expand Down Expand Up @@ -556,7 +587,8 @@ function resetCurrentVideo() {
function deleteSelectedItems() {
if (selectedFileNames.length === 0)
return;
LazyLoader.load('shared/style/confirm.css', function() {
LazyLoader.load(['shared/style/confirm.css',
'style/confirm.css'], function() {

Dialogs.confirm({
messageId: 'delete-n-items?',
Expand Down Expand Up @@ -721,6 +753,7 @@ function thumbnailClickHandler(videodata) {
stopParsingMetadata(function() {
var fullscreen = pendingPick || isPhone || isPortrait;
showPlayer(videodata, !pendingPick, fullscreen, pendingPick);
setSoftwareHomeButtonVisibility(false);
});
});
}
Expand Down Expand Up @@ -774,6 +807,7 @@ function showOverlay(id) {
}

function setControlsVisibility(visible) {

// in tablet landscape mode, we always shows controls in list layout. We
// don't need to hide it.
if (isPhone || isPortrait ||
Expand All @@ -785,6 +819,7 @@ function setControlsVisibility(visible) {
// always set it as shown.
controlShowing = true;
}

// to sync the slider under the case of auto-pause(unplugging headset), we
// need to update the slider when controls is visible.
if (controlShowing) {
Expand Down Expand Up @@ -830,7 +865,8 @@ function deleteCurrentVideo() {
// We need to disable NFC sharing when showing delete confirmation dialog
setNFCSharing(false);

LazyLoader.load('shared/style/confirm.css', function() {
LazyLoader.load(['shared/style/confirm.css',
'style/confirm.css'], function() {
// If we're deleting the file shown in the player we've got to
// return to the thumbnail list. We pass false to hidePlayer() to tell it
// not to record new metadata for the file we're about to delete.
Expand Down Expand Up @@ -989,7 +1025,6 @@ function showPlayer(video, autoPlay, enterFullscreen, keepControls) {
//hide video player before setVideoUrl
dom.player.hidden = true;
setVideoUrl(dom.player, currentVideo, function() {

if (enterFullscreen) {
switchLayout(LAYOUT_MODE.fullscreenPlayer);
}
Expand Down
1 change: 1 addition & 0 deletions apps/video/manifest.webapp
Expand Up @@ -8,6 +8,7 @@
"url": "https://github.com/mozilla-b2g/gaia"
},
"fullscreen": true,
"fullscreen_layout": true,
"permissions": {
"themeable":{},
"storage":{},
Expand Down
18 changes: 18 additions & 0 deletions apps/video/style/confirm.css
@@ -0,0 +1,18 @@
/*
* confirm dialog overrides for software home button
*/
@media not all and (-moz-physical-home-button) {
@media (orientation: portrait) {
form[role="dialog"][data-type="confirm"] menu {
left: 0;
bottom: 5rem;
}
}
@media (orientation: landscape) {
form[role="dialog"][data-type="confirm"] menu {
right: 5rem;
bottom: 0;
}
}
}

18 changes: 18 additions & 0 deletions apps/video/style/info.css
Expand Up @@ -39,3 +39,21 @@
/* no separator after the last item in the list */
border-bottom: none;
}

/*
* Overrides for software home button
*/
@media not all and (-moz-physical-home-button) {
@media (orientation: portrait) {
#info-view > menu button {
right: 0;
bottom: 5rem;
}
}
@media (orientation: landscape) {
#info-view > menu button {
right: 5rem;
bottom: 0;
}
}
}
66 changes: 66 additions & 0 deletions apps/video/style/video.css
Expand Up @@ -753,3 +753,69 @@ form[role="dialog"][data-type="confirm"] button.hidden {
border: none;
padding: 0;
}

/*
* Adjust video controls when software home button is present
*/
@media (orientation: portrait) {
#videoControls.software-button-present {
height: calc(100% - 5rem);
width: 100%;
}
}

@media (orientation: landscape) {
#videoControls.software-button-present {
height: 100%;
width: calc(100% - 5rem);
}
}

/*
* Overrides for software home button
*/
@media not all and (-moz-physical-home-button) {
@media (orientation: portrait) {
#thumbnail-list-view, #thumbnail-select-view {
height: calc(100% - 5rem);
width: 100%;
}

#options-view {
right: 0;
bottom: 5rem;
}

#options-cancel-button {
right: 0;
bottom: 5rem;
}
}

@media (orientation: landscape) {
#thumbnail-list-view, #thumbnail-select-view {
height: 100%;
width: calc(100% - 5rem);
}

#options-view {
right: 5rem;
bottom: 0;
}

/*
* options-cancel-button needs special treatment because its position
* is 'fixed'. In order for 'right' to be applied, set 'left: auto'.
* Adjust width by 5+3 ('5' because right is shifted by 5, '3' because
* width has already been shortened by 3 by here:
* '[role="dialog"][data-type="action"] > menu > button' in action_menu.css
*/
#options-cancel-button {
left: auto;
right: 5rem;
width: calc(100% - 8rem);
bottom: 0;
}
}
}

0 comments on commit eba8538

Please sign in to comment.