* Added a temporary solution to add the Audio:Length attribute to audio files,
just like SoundPlay did. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33812 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
|
#include <fs_attr.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
|
|
||||||
#include "AudioProducer.h"
|
#include "AudioProducer.h"
|
||||||
#include "ControllerObserver.h"
|
#include "ControllerObserver.h"
|
||||||
|
#include "FilePlaylistItem.h"
|
||||||
#include "MainApp.h"
|
#include "MainApp.h"
|
||||||
#include "PeakView.h"
|
#include "PeakView.h"
|
||||||
#include "PlaylistItem.h"
|
#include "PlaylistItem.h"
|
||||||
@@ -442,6 +444,7 @@ MainWin::MessageReceived(BMessage *msg)
|
|||||||
// TODO: move all other GUI changes as a reaction to this
|
// TODO: move all other GUI changes as a reaction to this
|
||||||
// notification
|
// notification
|
||||||
// _UpdatePlaylistMenu();
|
// _UpdatePlaylistMenu();
|
||||||
|
_SetFileAttributes();
|
||||||
break;
|
break;
|
||||||
case MSG_CONTROLLER_VIDEO_TRACK_CHANGED:
|
case MSG_CONTROLLER_VIDEO_TRACK_CHANGED:
|
||||||
{
|
{
|
||||||
@@ -1677,6 +1680,35 @@ MainWin::_ToggleNoInterface()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
/*! Sets some standard attributes of the currently played file.
|
||||||
|
This should only be a temporary solution.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
MainWin::_SetFileAttributes()
|
||||||
|
{
|
||||||
|
const FilePlaylistItem* item
|
||||||
|
= dynamic_cast<const FilePlaylistItem*>(fController->Item());
|
||||||
|
|
||||||
|
if (!fHasVideo && fHasAudio) {
|
||||||
|
BNode node(&item->Ref());
|
||||||
|
if (node.InitCheck())
|
||||||
|
return;
|
||||||
|
|
||||||
|
attr_info info;
|
||||||
|
status_t status = node.GetAttrInfo("Audio:Length", &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("Audio:Length", B_STRING_TYPE, 0, text,
|
||||||
|
strlen(text) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainWin::_UpdateControlsEnabledStatus()
|
MainWin::_UpdateControlsEnabledStatus()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ private:
|
|||||||
void _ToggleAlwaysOnTop();
|
void _ToggleAlwaysOnTop();
|
||||||
void _ToggleNoInterface();
|
void _ToggleNoInterface();
|
||||||
|
|
||||||
|
void _SetFileAttributes();
|
||||||
void _UpdateControlsEnabledStatus();
|
void _UpdateControlsEnabledStatus();
|
||||||
void _UpdatePlaylistMenu();
|
void _UpdatePlaylistMenu();
|
||||||
void _AddPlaylistItem(PlaylistItem* item,
|
void _AddPlaylistItem(PlaylistItem* item,
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ public:
|
|||||||
// playback
|
// playback
|
||||||
virtual BMediaFile* CreateMediaFile() const;
|
virtual BMediaFile* CreateMediaFile() const;
|
||||||
|
|
||||||
|
const entry_ref& Ref() const { return fRef; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
entry_ref fRef;
|
entry_ref fRef;
|
||||||
BString fNameInTrash;
|
BString fNameInTrash;
|
||||||
|
|||||||
Reference in New Issue
Block a user