* Rename a couple Audio:* attributes to Media:*, as discussed

some time ago on the mailing list. This change will not exactly
   break existing audio tools, but once those tools write the old
   attributes, the user will not see the expected changes when he
   is displaying the new attributes in Tracker, and the old
   attributes will of coerse appear alongside the new ones in
   the Attribute menu. In the long run, it makes things cleaner,
   though.
 * Make MediaPlayer write the new duration attribute, and also for
   video clips.
 * Register opened playlist items when they are files with the
   system, so not only files opened via drag and drop or Tracker
   will appear in MediaPlayers "Open File" menu.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38523 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-09-03 12:03:12 +00:00
parent 36f28785c6
commit 8ae6dbd9de
4 changed files with 87 additions and 42 deletions

View File

@ -2,7 +2,7 @@
* MainWin.cpp - Media Player for the Haiku Operating System * MainWin.cpp - Media Player for the Haiku Operating System
* *
* Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de> * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>
* Copyright (C) 2007-2009 Stephan Aßmus <superstippi@gmx.de> (GPL->MIT ok) * Copyright (C) 2007-2010 Stephan Aßmus <superstippi@gmx.de> (GPL->MIT ok)
* Copyright (C) 2007-2009 Fredrik Modéen <[FirstName]@[LastName].se> (MIT ok) * Copyright (C) 2007-2009 Fredrik Modéen <[FirstName]@[LastName].se> (MIT ok)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -529,14 +529,8 @@ MainWin::MessageReceived(BMessage* msg)
break; break;
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
printf("MainWin::MessageReceived: B_SIMPLE_DATA\n"); printf("MainWin::MessageReceived: B_SIMPLE_DATA\n");
if (msg->HasRef("refs")) { if (msg->HasRef("refs"))
// add to recent documents as it's not done with drag-n-drop
entry_ref ref;
for (int32 i = 0; msg->FindRef("refs", i, &ref) == B_OK; i++) {
be_roster->AddToRecentDocuments(&ref, kAppSig);
}
_RefsReceived(msg); _RefsReceived(msg);
}
break; break;
case M_OPEN_PREVIOUS_PLAYLIST: case M_OPEN_PREVIOUS_PLAYLIST:
OpenPlaylist(msg); OpenPlaylist(msg);
@ -1246,7 +1240,7 @@ MainWin::_PlaylistItemOpened(const PlaylistItemRef& item, status_t result)
_SetupWindow(); _SetupWindow();
if (result == B_OK) if (result == B_OK)
_SetFileAttributes(); _UpdatePlaylistItemFile();
} }
@ -1324,15 +1318,19 @@ MainWin::_CreateMenu()
new BMessage(M_FILE_NEWPLAYER), 'N')); new BMessage(M_FILE_NEWPLAYER), 'N'));
fFileMenu->AddSeparatorItem(); fFileMenu->AddSeparatorItem();
// fFileMenu->AddItem(new BMenuItem("Open File"B_UTF8_ELLIPSIS, #if 0
// new BMessage(M_FILE_OPEN), 'O')); // Plain "Open File" entry
// Add recent files fFileMenu->AddItem(new BMenuItem("Open File"B_UTF8_ELLIPSIS,
new BMessage(M_FILE_OPEN), 'O'));
#else
// Add recent files to "Open File" entry as sub-menu.
BRecentFilesList recentFiles(10, false, NULL, kAppSig); BRecentFilesList recentFiles(10, false, NULL, kAppSig);
BMenuItem* item = new BMenuItem(recentFiles.NewFileListMenu( BMenuItem* item = new BMenuItem(recentFiles.NewFileListMenu(
"Open file"B_UTF8_ELLIPSIS, new BMessage(B_REFS_RECEIVED), "Open file"B_UTF8_ELLIPSIS, new BMessage(B_REFS_RECEIVED),
NULL, this, 10, false, NULL, 0, kAppSig), new BMessage(M_FILE_OPEN)); NULL, this, 10, false, NULL, 0, kAppSig), new BMessage(M_FILE_OPEN));
item->SetShortcut('O', 0); item->SetShortcut('O', 0);
fFileMenu->AddItem(item); fFileMenu->AddItem(item);
#endif
fFileMenu->AddItem(new BMenuItem("File info"B_UTF8_ELLIPSIS, fFileMenu->AddItem(new BMenuItem("File info"B_UTF8_ELLIPSIS,
new BMessage(M_FILE_INFO), 'I')); new BMessage(M_FILE_INFO), 'I'));
@ -2136,11 +2134,8 @@ MainWin::_ShowFullscreenControls(bool show, bool animate)
// #pragma mark - // #pragma mark -
/*! Sets some standard attributes of the currently played file.
This should only be a temporary solution.
*/
void void
MainWin::_SetFileAttributes() MainWin::_UpdatePlaylistItemFile()
{ {
BAutolock locker(fPlaylist); BAutolock locker(fPlaylist);
const FilePlaylistItem* item const FilePlaylistItem* item
@ -2148,29 +2143,37 @@ MainWin::_SetFileAttributes()
if (item == NULL) if (item == NULL)
return; return;
if (!fHasVideo && fHasAudio) { if (!fHasVideo && !fHasAudio)
BNode node(&item->Ref()); return;
if (node.InitCheck())
return;
locker.Unlock(); BNode node(&item->Ref());
if (node.InitCheck())
return;
// write duration // Add to recent documents
be_roster->AddToRecentDocuments(&item->Ref(), kAppSig);
attr_info info; locker.Unlock();
status_t status = node.GetAttrInfo("Audio:Length", &info);
if (status != B_OK || info.size == 0) {
time_t duration = fController->TimeDuration() / 1000000L;
char text[256]; // Set some standard attributes of the currently played file.
snprintf(text, sizeof(text), "%02ld:%02ld", duration / 60, // This should only be a temporary solution.
duration % 60);
node.WriteAttr("Audio:Length", B_STRING_TYPE, 0, text,
strlen(text) + 1);
}
// write bitrate // Write duration
const char* kDurationAttrName = "Media:Length";
attr_info info;
status_t status = node.GetAttrInfo(kDurationAttrName, &info);
if (status != B_OK || info.size == 0) {
time_t duration = fController->TimeDuration() / 1000000L;
char text[256];
snprintf(text, sizeof(text), "%02ld:%02ld", duration / 60,
duration % 60);
node.WriteAttr(kDurationAttrName, B_STRING_TYPE, 0, text,
strlen(text) + 1);
}
// Write audio bitrate
if (fHasAudio && !fHasVideo) {
status = node.GetAttrInfo("Audio:Bitrate", &info); status = node.GetAttrInfo("Audio:Bitrate", &info);
if (status != B_OK || info.size == 0) { if (status != B_OK || info.size == 0) {
media_format format; media_format format;

View File

@ -2,7 +2,7 @@
* MainWin.h - Media Player for the Haiku Operating System * MainWin.h - Media Player for the Haiku Operating System
* *
* Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de> * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>
* Copyright (C) 2007-2009 Stephan Aßmus <superstippi@gmx.de> (MIT ok) * Copyright (C) 2007-2010 Stephan Aßmus <superstippi@gmx.de> (MIT ok)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -119,7 +119,7 @@ private:
void _ShowFullscreenControls(bool show, void _ShowFullscreenControls(bool show,
bool animate = true); bool animate = true);
void _SetFileAttributes(); void _UpdatePlaylistItemFile();
void _UpdateControlsEnabledStatus(); void _UpdateControlsEnabledStatus();
void _UpdatePlaylistMenu(); void _UpdatePlaylistMenu();
void _AddPlaylistItem(PlaylistItem* item, void _AddPlaylistItem(PlaylistItem* item,

View File

@ -15,14 +15,14 @@ resource(5, "META:EXTENS") message(234) {
resource(6, "META:ATTR_INFO") message(233) { resource(6, "META:ATTR_INFO") message(233) {
"attr:name" = "Audio:Artist", "attr:name" = "Audio:Artist",
"attr:name" = "Audio:Title", "attr:name" = "Media:Title",
"attr:name" = "Audio:Album", "attr:name" = "Audio:Album",
"attr:name" = "Audio:Track", "attr:name" = "Audio:Track",
"attr:name" = "Audio:Year", "attr:name" = "Media:Year",
"attr:name" = "Audio:Comment", "attr:name" = "Media:Comment",
"attr:name" = "Audio:Genre", "attr:name" = "Media:Genre",
"attr:name" = "Audio:Rating", "attr:name" = "Media:Rating",
"attr:name" = "Audio:Length", "attr:name" = "Media:Length",
"attr:name" = "Audio:Bitrate", "attr:name" = "Audio:Bitrate",
"attr:public_name" = "Artist", "attr:public_name" = "Artist",
"attr:public_name" = "Title", "attr:public_name" = "Title",

View File

@ -14,12 +14,54 @@ resource(5, "META:EXTENS") message(234) {
}; };
resource(6, "META:ATTR_INFO") message(233) { resource(6, "META:ATTR_INFO") message(233) {
"attr:name" = "Video:Length", "attr:name" = "Media:Title",
"attr:name" = "Media:Year",
"attr:name" = "Media:Comment",
"attr:name" = "Media:Genre",
"attr:name" = "Media:Rating",
"attr:name" = "Media:Length",
"attr:name" = "Video:Bitrate",
"attr:public_name" = "Title",
"attr:public_name" = "Year",
"attr:public_name" = "Comment",
"attr:public_name" = "Genre",
"attr:public_name" = "Rating",
"attr:public_name" = "Playing time", "attr:public_name" = "Playing time",
"attr:public_name" = "Video bitrate",
"attr:type" = 'CSTR',
"attr:type" = 'LONG',
"attr:type" = 'CSTR',
"attr:type" = 'CSTR',
"attr:type" = 'LONG',
"attr:type" = 'CSTR',
"attr:type" = 'CSTR', "attr:type" = 'CSTR',
"attr:viewable" = true, "attr:viewable" = true,
"attr:viewable" = true,
"attr:viewable" = true,
"attr:viewable" = true,
"attr:viewable" = true,
"attr:viewable" = true,
"attr:viewable" = true,
"attr:editable" = true,
"attr:editable" = true,
"attr:editable" = true,
"attr:editable" = true,
"attr:editable" = true,
"attr:editable" = false, "attr:editable" = false,
"attr:editable" = false,
"attr:width" = 30,
"attr:width" = 30,
"attr:width" = 40,
"attr:width" = 30,
"attr:width" = 15,
"attr:width" = 60, "attr:width" = 60,
"attr:width" = 50,
"attr:alignment" = 0,
"attr:alignment" = 0,
"attr:alignment" = 0,
"attr:alignment" = 0,
"attr:alignment" = 0,
"attr:alignment" = 1,
"attr:alignment" = 1, "attr:alignment" = 1,
"type" = "video" "type" = "video"
}; };