Permalink
Browse files

Merge pull request #7246 from davidflanagan/youtube6

Bug 821514 - display error message if youtube won't play video
  • Loading branch information...
2 parents 1084057 + 3e19095 commit a2b486b1e7e85aacedd1158cd6f29ff0bc468425 @daleharvey daleharvey committed Dec 29, 2012
View
@@ -6,7 +6,8 @@ var ids = ['player', 'thumbnails', 'overlay', 'overlay-title',
'overlay-text', 'videoControls', 'videoFrame', 'videoBar',
'close', 'play', 'playHead', 'timeSlider', 'elapsedTime',
'video-title', 'duration-text', 'elapsed-text', 'bufferedTime',
- 'slider-wrapper', 'throbber', 'delete-video-button', 'delete-confirmation-button'];
+ 'slider-wrapper', 'throbber', 'delete-video-button',
+ 'delete-confirmation-button'];
ids.forEach(function createElementRef(name) {
dom[toCamelCase(name)] = document.getElementById(name);
@@ -41,10 +42,6 @@ var THUMBNAIL_HEIGHT = 160;
// Enumerating the readyState for html5 video api
var HAVE_NOTHING = 0;
-var activityData; // From an activity call
-var pendingActivity;
-var appStarted = false;
-
var storageState;
var currentOverlay;
@@ -65,9 +62,6 @@ function init() {
storageState = false;
updateDialog();
createThumbnailList();
- if (activityData) {
- startStream();
- }
};
videodb.onscanstart = function() {
@@ -88,9 +82,8 @@ function init() {
event.detail.forEach(videoDeleted);
};
- dom.deleteConfirmationButton.addEventListener('click', deleteSelectedVideoFile, false);
-
- appStarted = true;
+ dom.deleteConfirmationButton.addEventListener('click',
+ deleteSelectedVideoFile, false);
}
function videoAdded(videodata) {
@@ -153,11 +146,11 @@ function videoAdded(videodata) {
dom.thumbnails.addEventListener('contextmenu', function(evt) {
var node = evt.target;
var found = false;
- while (!found && node) {
- if (node.dataset.name) {
+ while (!found && node) {
+ if (node.dataset.name) {
found = true;
selectedVideo = node.dataset.name;
- } else {
+ } else {
node = node.parentNode;
}
}
@@ -208,11 +201,6 @@ function updateDialog() {
}
}
-function startStream() {
- showPlayer(activityData, true);
- activityData = null;
-}
-
function metaDataParser(videofile, callback, metadataError) {
var previewPlayer = document.createElement('video');
@@ -372,12 +360,6 @@ function setVideoPlaying(playing) {
}
}
-function completeActivity(deleteVideo) {
- pendingActivity.postResult({delete: deleteVideo});
- pendingActivity = null;
- dom.thumbnails.classList.remove('hidden');
-}
-
function playerMousedown(event) {
// If we interact with the controls before they fade away,
// cancel the fade
@@ -602,14 +584,9 @@ function playerEnded() {
clearTimeout(endedTimer);
endedTimer = null;
}
- if (pendingActivity) {
- pause();
- dom.player.currentTime = 0;
- setControlsVisibility(true);
- } else {
- dom.player.currentTime = 0;
- document.mozCancelFullScreen();
- }
+
+ dom.player.currentTime = 0;
+ document.mozCancelFullScreen();
}
function play() {
@@ -762,33 +739,6 @@ function formatDuration(duration) {
return '';
}
-function actHandle(activity) {
- var data = activity.source.data;
- var title = 'extras' in data ? (data.extras.title || '') : '';
- switch (activity.source.name) {
- case 'open':
- // Activities are required to specify whether they are inline in the manifest
- // so we know we are inline, dont bother showing thumbnails
- dom.thumbnails.classList.add('hidden');
- pendingActivity = activity;
- var filename = data.src.replace(/^ds\:videos:\/\//, '');
- activityData = {
- fromMediaDB: false,
- name: filename,
- title: title
- };
- break;
- case 'view':
- activityData = {
- url: data.url,
- title: title
- };
- break;
- }
- if (appStarted) {
- startStream();
- }
-}
// The mozRequestFullScreen can fail silently, so we keep asking
// for full screen until we detect that it happens, We limit the
@@ -802,20 +752,12 @@ function requestFullScreen(callback) {
if (++requests > MAX_FULLSCREEN_REQUESTS) {
window.clearInterval(fullscreenTimer);
fullscreenTimer = null;
- if (pendingActivity) {
- pendingActivity.postError('Could not play video');
- pendingActivity = null;
- }
return;
}
dom.videoFrame.mozRequestFullScreen();
}, 500);
}
-if (window.navigator.mozSetMessageHandler) {
- window.navigator.mozSetMessageHandler('activity', actHandle);
-}
-
// When we exit fullscreen mode, stop playing the video.
// This happens automatically when the user uses the back button (because
// back is Escape, which is also the "leave fullscreen mode" command).
@@ -824,11 +766,7 @@ if (window.navigator.mozSetMessageHandler) {
document.addEventListener('mozfullscreenchange', function() {
// We have exited fullscreen
if (document.mozFullScreenElement === null) {
- if (pendingActivity) {
- completeActivity(false);
- } else {
- hidePlayer();
- }
+ hidePlayer();
return;
}
Oops, something went wrong.

0 comments on commit a2b486b

Please sign in to comment.