MediaPlayer: Add support code for url items
* It needs further work to avoid the AudioSupplier being recreated every time. It makes the BMediaFile to redo the sniffing process various times.
This commit is contained in:
@@ -59,8 +59,7 @@ ImportPLItemsCommand::ImportPLItemsCommand(Playlist* playlist,
|
|||||||
// init new entries
|
// init new entries
|
||||||
int32 added = 0;
|
int32 added = 0;
|
||||||
for (int32 i = 0; i < fNewCount; i++) {
|
for (int32 i = 0; i < fNewCount; i++) {
|
||||||
FilePlaylistItem* fileItem = dynamic_cast<FilePlaylistItem*>(temp.ItemAtFast(i));
|
if (!Playlist::ExtraMediaExists(playlist, temp.ItemAtFast(i))) {
|
||||||
if (fileItem && !Playlist::ExtraMediaExists(playlist, fileItem->Ref())) {
|
|
||||||
fNewItems[added] = temp.ItemAtFast(i)->Clone();
|
fNewItems[added] = temp.ItemAtFast(i)->Clone();
|
||||||
if (fNewItems[added] == NULL) {
|
if (fNewItems[added] == NULL) {
|
||||||
// indicate bad object init
|
// indicate bad object init
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ Playlist::AppendRefs(const BMessage* refsReceivedMessage, int32 appendIndex)
|
|||||||
if (_IsQuery(type))
|
if (_IsQuery(type))
|
||||||
AppendQueryToPlaylist(ref, &subPlaylist);
|
AppendQueryToPlaylist(ref, &subPlaylist);
|
||||||
else {
|
else {
|
||||||
if (!ExtraMediaExists(this, ref)) {
|
if (!_ExtraMediaExists(this, ref)) {
|
||||||
AppendToPlaylistRecursive(ref, &subPlaylist);
|
AppendToPlaylistRecursive(ref, &subPlaylist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -520,7 +520,7 @@ Playlist::AppendToPlaylistRecursive(const entry_ref& ref, Playlist* playlist)
|
|||||||
BString mimeString = _MIMEString(&ref);
|
BString mimeString = _MIMEString(&ref);
|
||||||
if (_IsMediaFile(mimeString)) {
|
if (_IsMediaFile(mimeString)) {
|
||||||
PlaylistItem* item = new (std::nothrow) FilePlaylistItem(ref);
|
PlaylistItem* item = new (std::nothrow) FilePlaylistItem(ref);
|
||||||
if (!ExtraMediaExists(playlist, ref)) {
|
if (!_ExtraMediaExists(playlist, ref)) {
|
||||||
_BindExtraMedia(item);
|
_BindExtraMedia(item);
|
||||||
if (item != NULL && !playlist->AddItem(item))
|
if (item != NULL && !playlist->AddItem(item))
|
||||||
delete item;
|
delete item;
|
||||||
@@ -601,7 +601,26 @@ Playlist::NotifyImportFailed()
|
|||||||
|
|
||||||
|
|
||||||
/*static*/ bool
|
/*static*/ bool
|
||||||
Playlist::ExtraMediaExists(Playlist* playlist, const entry_ref& ref)
|
Playlist::ExtraMediaExists(Playlist* playlist, PlaylistItem* item)
|
||||||
|
{
|
||||||
|
FilePlaylistItem* fileItem = dynamic_cast<FilePlaylistItem*>(item);
|
||||||
|
if (fileItem != NULL)
|
||||||
|
return _ExtraMediaExists(playlist, fileItem->Ref());
|
||||||
|
|
||||||
|
// If we are here let's see if it is an url
|
||||||
|
UrlPlaylistItem* urlItem = dynamic_cast<UrlPlaylistItem*>(item);
|
||||||
|
if (urlItem == NULL)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return _ExtraMediaExists(playlist, urlItem->Url());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - private
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/ bool
|
||||||
|
Playlist::_ExtraMediaExists(Playlist* playlist, const entry_ref& ref)
|
||||||
{
|
{
|
||||||
BString exceptExtension = _GetExceptExtension(BPath(&ref).Path());
|
BString exceptExtension = _GetExceptExtension(BPath(&ref).Path());
|
||||||
|
|
||||||
@@ -617,7 +636,18 @@ Playlist::ExtraMediaExists(Playlist* playlist, const entry_ref& ref)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - private
|
/*static*/ bool
|
||||||
|
Playlist::_ExtraMediaExists(Playlist* playlist, BUrl* url)
|
||||||
|
{
|
||||||
|
for (int32 i = 0; i < playlist->CountItems(); i++) {
|
||||||
|
UrlPlaylistItem* compare = dynamic_cast<UrlPlaylistItem*>(playlist->ItemAt(i));
|
||||||
|
if (compare == NULL)
|
||||||
|
continue;
|
||||||
|
if (compare->Url() != url)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*static*/ bool
|
/*static*/ bool
|
||||||
|
|||||||
@@ -24,9 +24,11 @@
|
|||||||
|
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
#include <Url.h>
|
||||||
|
|
||||||
#include "FilePlaylistItem.h"
|
#include "FilePlaylistItem.h"
|
||||||
#include "PlaylistItem.h"
|
#include "PlaylistItem.h"
|
||||||
|
#include "UrlPlaylistItem.h"
|
||||||
|
|
||||||
class BDataIO;
|
class BDataIO;
|
||||||
class BMessage;
|
class BMessage;
|
||||||
@@ -115,13 +117,15 @@ public:
|
|||||||
|
|
||||||
void NotifyImportFailed();
|
void NotifyImportFailed();
|
||||||
|
|
||||||
static bool ExtraMediaExists(Playlist* playlist, const entry_ref& ref);
|
static bool ExtraMediaExists(Playlist* playlist, PlaylistItem* item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Playlist(const Playlist& other);
|
Playlist(const Playlist& other);
|
||||||
Playlist& operator=(const Playlist& other);
|
Playlist& operator=(const Playlist& other);
|
||||||
// unimplemented
|
// unimplemented
|
||||||
|
|
||||||
|
static bool _ExtraMediaExists(Playlist* playlist, const entry_ref& ref);
|
||||||
|
static bool _ExtraMediaExists(Playlist* playlist, BUrl* url);
|
||||||
static bool _IsImageFile(const BString& mimeString);
|
static bool _IsImageFile(const BString& mimeString);
|
||||||
static bool _IsMediaFile(const BString& mimeString);
|
static bool _IsMediaFile(const BString& mimeString);
|
||||||
static bool _IsTextPlaylist(const BString& mimeString);
|
static bool _IsTextPlaylist(const BString& mimeString);
|
||||||
|
|||||||
Reference in New Issue
Block a user