diff options
author | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 19:38:07 +0000 |
---|---|---|
committer | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 19:38:07 +0000 |
commit | 89a7e381b642298e5d96f2416a569fc1c8828614 (patch) | |
tree | 04cdfd99e8a27c41b301fdd32bf076ff460598ec | |
parent | 90ba32fe7f160ceb35e342e9cf290f0602622f79 (diff) | |
download | chromium_src-89a7e381b642298e5d96f2416a569fc1c8828614.zip chromium_src-89a7e381b642298e5d96f2416a569fc1c8828614.tar.gz chromium_src-89a7e381b642298e5d96f2416a569fc1c8828614.tar.bz2 |
Changing the behavior so that clicking on an item forces a playback, and enqueueing an item is available from the menu.
Review URL: http://codereview.chromium.org/2436008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48749 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 3 | ||||
-rw-r--r-- | chrome/browser/dom_ui/filebrowse_ui.cc | 31 | ||||
-rw-r--r-- | chrome/browser/resources/filebrowse.html | 12 |
3 files changed, 45 insertions, 1 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 693ab4d..e6a4b63 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7357,6 +7357,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FILEBROWSER_DELETE" desc="Delete file menu item"> Delete </message> + <message name="IDS_FILEBROWSER_ENQUEUE" desc="Enqueue file menu item used for media playback"> + Enqueue + </message> <!-- Chrome OS Strings --> <if expr="pp_ifdef('chromeos')"> diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index 1be3402..4818cff 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.cc +++ b/chrome/browser/dom_ui/filebrowse_ui.cc @@ -158,6 +158,7 @@ class FilebrowseHandler : public net::DirectoryLister::DirectoryListerDelegate, void HandleCreateNewFolder(const Value* value); void PlayMediaFile(const Value* value); + void EnqueueMediaFile(const Value* value); void HandleDeleteFile(const Value* value); void DeleteFile(const FilePath& path); @@ -295,7 +296,8 @@ void FileBrowseUIHTMLSource::StartDataRequest(const std::string& path, l10n_util::GetString(IDS_FILEBROWSER_UPLOAD_EMAIL)); localized_strings.SetString(L"delete", l10n_util::GetString(IDS_FILEBROWSER_DELETE)); - + localized_strings.SetString(L"enqueue", + l10n_util::GetString(IDS_FILEBROWSER_ENQUEUE)); SetFontAndTextDirection(&localized_strings); static const base::StringPiece filebrowse_html( @@ -404,6 +406,8 @@ void FilebrowseHandler::RegisterMessages() { NewCallback(this, &FilebrowseHandler::HandleCreateNewFolder)); dom_ui_->RegisterMessageCallback("playMediaFile", NewCallback(this, &FilebrowseHandler::PlayMediaFile)); + dom_ui_->RegisterMessageCallback("enqueueMediaFile", + NewCallback(this, &FilebrowseHandler::EnqueueMediaFile)); dom_ui_->RegisterMessageCallback("pauseToggleDownload", NewCallback(this, &FilebrowseHandler::HandlePauseToggleDownload)); dom_ui_->RegisterMessageCallback("deleteFile", @@ -568,6 +572,31 @@ void FilebrowseHandler::PlayMediaFile(const Value* value) { GURL gurl(url); + mediaplayer->ForcePlayMediaURL(gurl); + } else { + LOG(ERROR) << "Unable to get string"; + return; + } + } +#endif +} + +void FilebrowseHandler::EnqueueMediaFile(const Value* value) { +#if defined(OS_CHROMEOS) + if (value && value->GetType() == Value::TYPE_LIST) { + const ListValue* list_value = static_cast<const ListValue*>(value); + std::string path; + + // Get path string. + if (list_value->GetString(0, &path)) { + FilePath currentpath; + currentpath = FilePath(path); + + MediaPlayer* mediaplayer = MediaPlayer::Get(); + std::string url = currentpath.value(); + + GURL gurl(url); + mediaplayer->EnqueueMediaURL(gurl); } else { LOG(ERROR) << "Unable to get string"; diff --git a/chrome/browser/resources/filebrowse.html b/chrome/browser/resources/filebrowse.html index bdc7ef9..79b43b5 100644 --- a/chrome/browser/resources/filebrowse.html +++ b/chrome/browser/resources/filebrowse.html @@ -1296,6 +1296,11 @@ function playMediaFile(path) { } } +function enqueueMediaFile(path) { + var newPath = 'file://' + path; + chrome.send('enqueueMediaFile', [newPath]); +} + function showImage(path) { if (inFullMode) { if (photoPreviewElement == null) { @@ -1495,6 +1500,13 @@ function createNewItem(title, path, isDirectory) { menu.appendChild(flickritem); menu.appendChild(emailitem); } + if (pathIsVideoFile(path) || pathIsAudioFile(path)) { + var enqueueitem = document.createElement('div'); + enqueueitem.textContent = localStrings.getString('enqueue'); + enqueueitem.className = 'menuitem'; + enqueueitem.onclick = partial(enqueueMediaFile, path); + menu.appendChild(enqueueitem); + } var deleteitem = document.createElement('div'); deleteitem.textContent = localStrings.getString('delete'); deleteitem.className = 'menuitem'; |