MediaPlayer: GuessMimeType() if no supertype and traverse link
... (to handle media files symlinked to volumes w/o attributes). Change-Id: I0ef2caa557769fee4781cd0ed44ff33d69e64103 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10006 Reviewed-by: Adrien Destugues <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
3329194a32
commit
4b5001248d
@@ -523,7 +523,7 @@ Playlist::AppendToPlaylistRecursive(const entry_ref& ref, Playlist* playlist)
|
|||||||
}
|
}
|
||||||
} else if (entry.IsFile()) {
|
} else if (entry.IsFile()) {
|
||||||
BString mimeString = _MIMEString(&ref);
|
BString mimeString = _MIMEString(&ref);
|
||||||
if (_IsMediaFile(mimeString)) {
|
if (_IsMediaFile(mimeString, ref)) {
|
||||||
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);
|
||||||
@@ -673,11 +673,28 @@ Playlist::_IsImageFile(const BString& mimeString)
|
|||||||
|
|
||||||
|
|
||||||
/*static*/ bool
|
/*static*/ bool
|
||||||
Playlist::_IsMediaFile(const BString& mimeString)
|
Playlist::_IsMediaFile(const BString& mimeString, const entry_ref& ref)
|
||||||
{
|
{
|
||||||
BMimeType superType;
|
BMimeType superType;
|
||||||
BMimeType fileType(mimeString.String());
|
BMimeType fileType(mimeString.String());
|
||||||
|
|
||||||
|
if (fileType.GetSupertype(&superType) != B_OK) {
|
||||||
|
// no superType, try to sniff the type
|
||||||
|
if (BMimeType::GuessMimeType(&ref, &fileType) != B_OK)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BEntry entry(&ref);
|
||||||
|
if (entry.IsSymLink()) {
|
||||||
|
// traverse link
|
||||||
|
entry_ref* fileRef = const_cast<entry_ref*>(&ref);
|
||||||
|
if (entry.SetTo(fileRef, true) != B_OK)
|
||||||
|
return false;
|
||||||
|
if (entry.GetRef(fileRef) != B_OK)
|
||||||
|
return false;
|
||||||
|
fileType.SetTo(_MIMEString(fileRef));
|
||||||
|
}
|
||||||
|
|
||||||
if (fileType.GetSupertype(&superType) != B_OK)
|
if (fileType.GetSupertype(&superType) != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -699,7 +716,7 @@ Playlist::_IsMediaFile(const BString& mimeString)
|
|||||||
|
|
||||||
const char* type;
|
const char* type;
|
||||||
for (int32 i = 0; types.FindString("types", i, &type) == B_OK; i++) {
|
for (int32 i = 0; types.FindString("types", i, &type) == B_OK; i++) {
|
||||||
if (strcasecmp(mimeString.String(), type) == 0)
|
if (strcasecmp(fileType.Type(), type) == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -791,7 +808,7 @@ Playlist::_BindExtraMedia(FilePlaylistItem* fileItem, const BEntry& entry)
|
|||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
entry.GetRef(&ref);
|
entry.GetRef(&ref);
|
||||||
BString mimeString = _MIMEString(&ref);
|
BString mimeString = _MIMEString(&ref);
|
||||||
if (_IsMediaFile(mimeString)) {
|
if (_IsMediaFile(mimeString, ref)) {
|
||||||
fileItem->AddRef(ref);
|
fileItem->AddRef(ref);
|
||||||
} else if (_IsImageFile(mimeString)) {
|
} else if (_IsImageFile(mimeString)) {
|
||||||
fileItem->AddImageRef(ref);
|
fileItem->AddImageRef(ref);
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ private:
|
|||||||
static bool _ExtraMediaExists(Playlist* playlist,
|
static bool _ExtraMediaExists(Playlist* playlist,
|
||||||
BUrl url);
|
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, const entry_ref& ref);
|
||||||
static bool _IsTextPlaylist(const BString& mimeString);
|
static bool _IsTextPlaylist(const BString& mimeString);
|
||||||
static bool _IsBinaryPlaylist(const BString& mimeString);
|
static bool _IsBinaryPlaylist(const BString& mimeString);
|
||||||
static bool _IsPlaylist(const BString& mimeString);
|
static bool _IsPlaylist(const BString& mimeString);
|
||||||
|
|||||||
Reference in New Issue
Block a user