Author: stippi Date: 2010-09-03 14:03:12 +0200 (Fri, 03 Sep 2010) New Revision: 38523 Changeset: http://dev.haiku-os.org/changeset/38523 Modified: haiku/trunk/src/apps/mediaplayer/MainWin.cpp haiku/trunk/src/apps/mediaplayer/MainWin.h haiku/trunk/src/data/beos_mime/audio.super haiku/trunk/src/data/beos_mime/video.super Log: * 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. Modified: haiku/trunk/src/apps/mediaplayer/MainWin.cpp =================================================================== --- haiku/trunk/src/apps/mediaplayer/MainWin.cpp 2010-09-03 10:20:29 UTC (rev 38522) +++ haiku/trunk/src/apps/mediaplayer/MainWin.cpp 2010-09-03 12:03:12 UTC (rev 38523) @@ -2,7 +2,7 @@ * MainWin.cpp - Media Player for the Haiku Operating System * * Copyright (C) 2006 Marcus Overhagen <marcus@xxxxxxxxxxxx> - * Copyright (C) 2007-2009 Stephan Aßmus <superstippi@xxxxxx> (GPL->MIT ok) + * Copyright (C) 2007-2010 Stephan Aßmus <superstippi@xxxxxx> (GPL->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 @@ -529,14 +529,8 @@ break; case B_SIMPLE_DATA: printf("MainWin::MessageReceived: B_SIMPLE_DATA\n"); - 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); - } + if (msg->HasRef("refs")) _RefsReceived(msg); - } break; case M_OPEN_PREVIOUS_PLAYLIST: OpenPlaylist(msg); @@ -1246,7 +1240,7 @@ _SetupWindow(); if (result == B_OK) - _SetFileAttributes(); + _UpdatePlaylistItemFile(); } @@ -1324,15 +1318,19 @@ new BMessage(M_FILE_NEWPLAYER), 'N')); fFileMenu->AddSeparatorItem(); -// fFileMenu->AddItem(new BMenuItem("Open File"B_UTF8_ELLIPSIS, -// new BMessage(M_FILE_OPEN), 'O')); - // Add recent files +#if 0 + // Plain "Open File" entry + 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); BMenuItem* item = new BMenuItem(recentFiles.NewFileListMenu( "Open file"B_UTF8_ELLIPSIS, new BMessage(B_REFS_RECEIVED), NULL, this, 10, false, NULL, 0, kAppSig), new BMessage(M_FILE_OPEN)); item->SetShortcut('O', 0); fFileMenu->AddItem(item); +#endif fFileMenu->AddItem(new BMenuItem("File info"B_UTF8_ELLIPSIS, new BMessage(M_FILE_INFO), 'I')); @@ -2136,11 +2134,8 @@ // #pragma mark - -/*! Sets some standard attributes of the currently played file. - This should only be a temporary solution. -*/ void -MainWin::_SetFileAttributes() +MainWin::_UpdatePlaylistItemFile() { BAutolock locker(fPlaylist); const FilePlaylistItem* item @@ -2148,29 +2143,37 @@ if (item == NULL) return; - if (!fHasVideo && fHasAudio) { - BNode node(&item->Ref()); - if (node.InitCheck()) - return; + if (!fHasVideo && !fHasAudio) + 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; - status_t status = node.GetAttrInfo("Audio:Length", &info); - if (status != B_OK || info.size == 0) { - time_t duration = fController->TimeDuration() / 1000000L; + locker.Unlock(); - char text[256]; - snprintf(text, sizeof(text), "%02ld:%02ld", duration / 60, - duration % 60); - node.WriteAttr("Audio:Length", B_STRING_TYPE, 0, text, - strlen(text) + 1); - } + // Set some standard attributes of the currently played file. + // This should only be a temporary solution. - // 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); if (status != B_OK || info.size == 0) { media_format format; Modified: haiku/trunk/src/apps/mediaplayer/MainWin.h =================================================================== --- haiku/trunk/src/apps/mediaplayer/MainWin.h 2010-09-03 10:20:29 UTC (rev 38522) +++ haiku/trunk/src/apps/mediaplayer/MainWin.h 2010-09-03 12:03:12 UTC (rev 38523) @@ -2,7 +2,7 @@ * MainWin.h - Media Player for the Haiku Operating System * * Copyright (C) 2006 Marcus Overhagen <marcus@xxxxxxxxxxxx> - * Copyright (C) 2007-2009 Stephan Aßmus <superstippi@xxxxxx> (MIT ok) + * Copyright (C) 2007-2010 Stephan Aßmus <superstippi@xxxxxx> (MIT ok) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -119,7 +119,7 @@ void _ShowFullscreenControls(bool show, bool animate = true); - void _SetFileAttributes(); + void _UpdatePlaylistItemFile(); void _UpdateControlsEnabledStatus(); void _UpdatePlaylistMenu(); void _AddPlaylistItem(PlaylistItem* item, Modified: haiku/trunk/src/data/beos_mime/audio.super =================================================================== --- haiku/trunk/src/data/beos_mime/audio.super 2010-09-03 10:20:29 UTC (rev 38522) +++ haiku/trunk/src/data/beos_mime/audio.super 2010-09-03 12:03:12 UTC (rev 38523) @@ -15,14 +15,14 @@ resource(6, "META:ATTR_INFO") message(233) { "attr:name" = "Audio:Artist", - "attr:name" = "Audio:Title", + "attr:name" = "Media:Title", "attr:name" = "Audio:Album", "attr:name" = "Audio:Track", - "attr:name" = "Audio:Year", - "attr:name" = "Audio:Comment", - "attr:name" = "Audio:Genre", - "attr:name" = "Audio:Rating", - "attr:name" = "Audio:Length", + "attr:name" = "Media:Year", + "attr:name" = "Media:Comment", + "attr:name" = "Media:Genre", + "attr:name" = "Media:Rating", + "attr:name" = "Media:Length", "attr:name" = "Audio:Bitrate", "attr:public_name" = "Artist", "attr:public_name" = "Title", Modified: haiku/trunk/src/data/beos_mime/video.super =================================================================== --- haiku/trunk/src/data/beos_mime/video.super 2010-09-03 10:20:29 UTC (rev 38522) +++ haiku/trunk/src/data/beos_mime/video.super 2010-09-03 12:03:12 UTC (rev 38523) @@ -14,13 +14,55 @@ }; 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" = "Video bitrate", "attr:type" = 'CSTR', + "attr:type" = 'LONG', + "attr:type" = 'CSTR', + "attr:type" = 'CSTR', + "attr:type" = 'LONG', + "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:editable" = true, + "attr:editable" = true, + "attr:editable" = true, + "attr:editable" = true, + "attr:editable" = true, "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" = 50, + "attr:alignment" = 0, + "attr:alignment" = 0, + "attr:alignment" = 0, + "attr:alignment" = 0, + "attr:alignment" = 0, "attr:alignment" = 1, + "attr:alignment" = 1, "type" = "video" };