* Created icons for MediaPlayer playlists
* Properly register playlist mimetype in MediaPlayer. Double clicking them will now open them in MediaPlayer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34143 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Binary file not shown.
@@ -28,7 +28,9 @@
|
|||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
#include <MediaRoster.h>
|
#include <MediaRoster.h>
|
||||||
|
#include <MimeType.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <Resources.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -36,6 +38,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "EventQueue.h"
|
#include "EventQueue.h"
|
||||||
|
#include "Playlist.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "SettingsWindow.h"
|
#include "SettingsWindow.h"
|
||||||
|
|
||||||
@@ -161,6 +164,8 @@ MainApp::ReadyToRun()
|
|||||||
fSettingsWindow = new SettingsWindow(BRect(150, 150, 450, 520));
|
fSettingsWindow = new SettingsWindow(BRect(150, 150, 450, 520));
|
||||||
fSettingsWindow->Hide();
|
fSettingsWindow->Hide();
|
||||||
fSettingsWindow->Show();
|
fSettingsWindow->Show();
|
||||||
|
|
||||||
|
_InstallPlaylistMimeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -549,6 +554,90 @@ MainApp::_RestoreCurrentPlaylist(BMessage* message) const
|
|||||||
return message->Unflatten(&file);
|
return message->Unflatten(&file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainApp::_InstallPlaylistMimeType()
|
||||||
|
{
|
||||||
|
// install mime type of documents
|
||||||
|
BMimeType mime(kBinaryPlaylistMimeString);
|
||||||
|
status_t ret = mime.InitCheck();
|
||||||
|
if (ret != B_OK) {
|
||||||
|
fprintf(stderr, "Could not init native document mime type (%s): %s.\n",
|
||||||
|
kBinaryPlaylistMimeString, strerror(ret));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mime.IsInstalled() && !(modifiers() & B_SHIFT_KEY)) {
|
||||||
|
// mime is already installed, and the user is not
|
||||||
|
// pressing the shift key to force a re-install
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mime.Install();
|
||||||
|
if (ret != B_OK && ret != B_FILE_EXISTS) {
|
||||||
|
fprintf(stderr, "Could not install native document mime type (%s): %s.\n",
|
||||||
|
kBinaryPlaylistMimeString, strerror(ret));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// set preferred app
|
||||||
|
ret = mime.SetPreferredApp(kAppSig);
|
||||||
|
if (ret != B_OK) {
|
||||||
|
fprintf(stderr, "Could not set native document preferred app: %s\n",
|
||||||
|
strerror(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
// set descriptions
|
||||||
|
ret = mime.SetShortDescription("MediaPlayer Playlist");
|
||||||
|
if (ret != B_OK) {
|
||||||
|
fprintf(stderr, "Could not set short description of mime type: %s\n",
|
||||||
|
strerror(ret));
|
||||||
|
}
|
||||||
|
ret = mime.SetLongDescription("MediaPlayer binary playlist file");
|
||||||
|
if (ret != B_OK) {
|
||||||
|
fprintf(stderr, "Could not set long description of mime type: %s\n",
|
||||||
|
strerror(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
// set extensions
|
||||||
|
BMessage message('extn');
|
||||||
|
message.AddString("extensions", "playlist");
|
||||||
|
ret = mime.SetFileExtensions(&message);
|
||||||
|
if (ret != B_OK) {
|
||||||
|
fprintf(stderr, "Could not set extensions of mime type: %s\n",
|
||||||
|
strerror(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
// set sniffer rule
|
||||||
|
char snifferRule[32];
|
||||||
|
uint32 bigEndianMagic = B_HOST_TO_BENDIAN_INT32(kPlaylistMagicBytes);
|
||||||
|
sprintf(snifferRule, "0.9 ('%4s')", (const char*)&bigEndianMagic);
|
||||||
|
ret = mime.SetSnifferRule(snifferRule);
|
||||||
|
if (ret != B_OK) {
|
||||||
|
BString parseError;
|
||||||
|
BMimeType::CheckSnifferRule(snifferRule, &parseError);
|
||||||
|
fprintf(stderr, "Could not set sniffer rule of mime type: %s\n",
|
||||||
|
parseError.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
// set playlist icon
|
||||||
|
BResources* resources = AppResources();
|
||||||
|
// does not need to be freed (belongs to BApplication base)
|
||||||
|
if (resources != NULL) {
|
||||||
|
size_t size;
|
||||||
|
const void* iconData = resources->LoadResource('VICN', "PlaylistIcon",
|
||||||
|
&size);
|
||||||
|
if (iconData != NULL && size > 0) {
|
||||||
|
if (mime.SetIcon(reinterpret_cast<const uint8*>(iconData), size)
|
||||||
|
!= B_OK) {
|
||||||
|
fprintf(stderr, "Could not set vector icon of mime type.\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Could not find icon in app resources "
|
||||||
|
"(data: %p, size: %ld).\n", iconData, size);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
fprintf(stderr, "Could not find app resources.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - main
|
// #pragma mark - main
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ private:
|
|||||||
status_t _RestoreCurrentPlaylist(
|
status_t _RestoreCurrentPlaylist(
|
||||||
BMessage* message) const;
|
BMessage* message) const;
|
||||||
|
|
||||||
|
void _InstallPlaylistMimeType();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32 fPlayerCount;
|
int32 fPlayerCount;
|
||||||
SettingsWindow* fSettingsWindow;
|
SettingsWindow* fSettingsWindow;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ resource app_version {
|
|||||||
resource app_flags B_SINGLE_LAUNCH;
|
resource app_flags B_SINGLE_LAUNCH;
|
||||||
|
|
||||||
resource file_types message {
|
resource file_types message {
|
||||||
|
"types" = "application/x-vnd.haiku-playlist",
|
||||||
|
|
||||||
"types" = "application/ogg",
|
"types" = "application/ogg",
|
||||||
"types" = "application/x-ogg",
|
"types" = "application/x-ogg",
|
||||||
"types" = "application/x-asf",
|
"types" = "application/x-asf",
|
||||||
@@ -95,3 +97,24 @@ resource vector_icon {
|
|||||||
$"020E0F1815FF01178400040A09020E0F0815FF"
|
$"020E0F1815FF01178400040A09020E0F0815FF"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resource("PlaylistIcon") #'VICN' array {
|
||||||
|
$"6E6369660805010401920200060338D2F73CD163BF82B23B84A94B885046E193"
|
||||||
|
$"00A5C5FFBDEAF2FFFFD5E3FF020106023C71C43DE4E9BCEEA63BAE5F49867748"
|
||||||
|
$"01ECFFD8E4FA7C7794C9020106023C34913DBF47BD1EE83BAC5E49EA70498C6D"
|
||||||
|
$"FFD8E2F37C6385C2020106023E49240000000000003CAAAA4940004A3000FED8"
|
||||||
|
$"E4FA7C7794C9020016023A66BABB23523D88443CB3F9489F5D48C17C0001FF27"
|
||||||
|
$"020106023A7E6FBB109D3DA2AF3CF54A495C2B486FDC00485C85FFBBCFF70E0A"
|
||||||
|
$"07485E4A5E4C5F6043573D455D475D0606AE0BB40BBC1D33C07FB72CBE903C47"
|
||||||
|
$"C13EC408CA28BA52C118B656C51BB876BF07B53E3A230605AE02B40BBF4D33C3"
|
||||||
|
$"AFB73CC1A43D50C13EC79ECA28BD823AB6BC0605AE02B40BC27D33C6DFB75DC4"
|
||||||
|
$"A3BDEFC937C13ECB34CA28C0B23AB9EC0606AE0BB40BBF4D33C3AFB75DC173BD"
|
||||||
|
$"EFC607C13EC804CA28BD82C118B920C51BBB40BF07B8083AB6BC0605AE02B57D"
|
||||||
|
$"3EB9B9C3EFB7BB44BBB751BD75C936CA8EC1B1402F0A093B593D5BBFCDC93E45"
|
||||||
|
$"5BC516C5F160465B435D4544510A045A425E3F5A3D5740060AAFBF0E3B4A3848"
|
||||||
|
$"BF6AC4D6414145443D3E363CBF4DBB374B3C4B3C483D49454643C4FEC2D84F3C"
|
||||||
|
$"533F4B393B302E3A3D413D413A4208024049543308023B454E3008023541492D"
|
||||||
|
$"0802303D432A08022A393E25090A010100000A0001031001178400040A040103"
|
||||||
|
$"000A0001021001178400040A030102000A0001011001178400040A020101000A"
|
||||||
|
$"0705090A0B0C0D1815FF01178100040A060108202018"
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -166,10 +166,9 @@ Playlist::Archive(BMessage* into) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kPlaylistMagicBytes = 'MPPL';
|
const uint32 kPlaylistMagicBytes = 'MPPL';
|
||||||
static const char* kTextPlaylistMimeString = "text/x-playlist";
|
const char* kTextPlaylistMimeString = "text/x-playlist";
|
||||||
static const char* kBinaryPlaylistMimeString
|
const char* kBinaryPlaylistMimeString = "application/x-vnd.haiku-playlist";
|
||||||
= "application/x-vnd.haiku-playlist";
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Playlist::Unflatten(BDataIO* stream)
|
Playlist::Unflatten(BDataIO* stream)
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ class BString;
|
|||||||
struct entry_ref;
|
struct entry_ref;
|
||||||
|
|
||||||
|
|
||||||
|
extern const uint32 kPlaylistMagicBytes;
|
||||||
|
extern const char* kTextPlaylistMimeString;
|
||||||
|
extern const char* kBinaryPlaylistMimeString;
|
||||||
|
|
||||||
|
|
||||||
class Playlist : public BLocker {
|
class Playlist : public BLocker {
|
||||||
public:
|
public:
|
||||||
class Listener {
|
class Listener {
|
||||||
|
|||||||
Reference in New Issue
Block a user