From 8ae6dbd9dee7847e2139b1e0b1338a21294ee789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 3 Sep 2010 12:03:12 +0000 Subject: [PATCH] * 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 --- src/apps/mediaplayer/MainWin.cpp | 69 +++++++++++++++++--------------- src/apps/mediaplayer/MainWin.h | 4 +- src/data/beos_mime/audio.super | 12 +++--- src/data/beos_mime/video.super | 44 +++++++++++++++++++- 4 files changed, 87 insertions(+), 42 deletions(-) diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 2e1862df6d..5ac9fb41d0 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -2,7 +2,7 @@ * MainWin.cpp - Media Player for the Haiku Operating System * * Copyright (C) 2006 Marcus Overhagen - * Copyright (C) 2007-2009 Stephan Aßmus (GPL->MIT ok) + * Copyright (C) 2007-2010 Stephan Aßmus (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 @@ MainWin::MessageReceived(BMessage* msg) 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 @@ MainWin::_PlaylistItemOpened(const PlaylistItemRef& item, status_t result) _SetupWindow(); if (result == B_OK) - _SetFileAttributes(); + _UpdatePlaylistItemFile(); } @@ -1324,15 +1318,19 @@ MainWin::_CreateMenu() 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 @@ MainWin::_ShowFullscreenControls(bool show, bool animate) // #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 @@ MainWin::_SetFileAttributes() 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; diff --git a/src/apps/mediaplayer/MainWin.h b/src/apps/mediaplayer/MainWin.h index 73cf6652d0..8c8540cbdd 100644 --- a/src/apps/mediaplayer/MainWin.h +++ b/src/apps/mediaplayer/MainWin.h @@ -2,7 +2,7 @@ * MainWin.h - Media Player for the Haiku Operating System * * Copyright (C) 2006 Marcus Overhagen - * Copyright (C) 2007-2009 Stephan Aßmus (MIT ok) + * Copyright (C) 2007-2010 Stephan Aßmus (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 @@ private: void _ShowFullscreenControls(bool show, bool animate = true); - void _SetFileAttributes(); + void _UpdatePlaylistItemFile(); void _UpdateControlsEnabledStatus(); void _UpdatePlaylistMenu(); void _AddPlaylistItem(PlaylistItem* item, diff --git a/src/data/beos_mime/audio.super b/src/data/beos_mime/audio.super index 9f4371ddc4..c6fecf297c 100644 --- a/src/data/beos_mime/audio.super +++ b/src/data/beos_mime/audio.super @@ -15,14 +15,14 @@ resource(5, "META:EXTENS") message(234) { 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", diff --git a/src/data/beos_mime/video.super b/src/data/beos_mime/video.super index bab763066f..3581c29ce1 100644 --- a/src/data/beos_mime/video.super +++ b/src/data/beos_mime/video.super @@ -14,12 +14,54 @@ resource(5, "META:EXTENS") message(234) { }; 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" };