Fix type-based window-targeting
This commit is contained in:
parent
fca0d597ec
commit
b266e9ca53
|
@ -152,19 +152,24 @@ MediaPlayer::Window()
|
||||||
|
|
||||||
fWindowTargetHops = kTargetHops;
|
fWindowTargetHops = kTargetHops;
|
||||||
|
|
||||||
|
Song current;
|
||||||
|
CurrentItem(¤t, false);
|
||||||
|
|
||||||
for (int32 i = CountWindows() - 1; i >= 0; i--) {
|
for (int32 i = CountWindows() - 1; i >= 0; i--) {
|
||||||
MediaPlayer mp(i, MP_BY_INDEX);
|
MediaPlayer mp(i, MP_BY_INDEX);
|
||||||
if (mp.IsValid()) {
|
if (mp.IsValid()) {
|
||||||
if (fWindowTarget == MP_BY_LATEST)
|
if (fWindowTarget == MP_BY_LATEST)
|
||||||
return i;
|
return fWindowIndex = i;
|
||||||
|
|
||||||
Song current;
|
Song mpcurrent;
|
||||||
BString type;
|
mp.CurrentItem(&mpcurrent, false);
|
||||||
if (CurrentItem(¤t, false)
|
|
||||||
&& BNode(current.Path().Path()).ReadAttrString("BEOS:TYPE", &type) == B_OK)
|
// If the current item's type is correct, we'll keep it
|
||||||
if ((type.StartsWith("audio") && fWindowTarget == MP_BY_TYPE_AUDIO)
|
if (!current.InitCheck() || !_MatchesTypeTarget(current.Type(), fWindowTarget))
|
||||||
|| (type.StartsWith("video") && fWindowTarget == MP_BY_TYPE_VIDEO))
|
if (mpcurrent.InitCheck() && _MatchesTypeTarget(mpcurrent.Type(), fWindowTarget))
|
||||||
return i;
|
return fWindowIndex = i;
|
||||||
|
else
|
||||||
|
fWindowIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fWindowIndex;
|
return fWindowIndex;
|
||||||
|
@ -259,6 +264,14 @@ MediaPlayer::_ScriptingCall(const char* attribute, BMessage* send, BMessage* rep
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
MediaPlayer::_MatchesTypeTarget(BString mimetype, target typeTarget)
|
||||||
|
{
|
||||||
|
return (mimetype.StartsWith("video") && typeTarget == MP_BY_TYPE_VIDEO)
|
||||||
|
|| (mimetype.StartsWith("audio") && typeTarget == MP_BY_TYPE_AUDIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
MediaPlayer::_UriToPath(BString URI)
|
MediaPlayer::_UriToPath(BString URI)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
void _ScriptingCall(const char* attribute, BMessage* send, BMessage* reply,
|
void _ScriptingCall(const char* attribute, BMessage* send, BMessage* reply,
|
||||||
int32 trackIndex = MP_NO_TRACK, bool window = true);
|
int32 trackIndex = MP_NO_TRACK, bool window = true);
|
||||||
|
|
||||||
|
bool _MatchesTypeTarget(BString mimetype, target typeTarget);
|
||||||
const char* _UriToPath(BString URI);
|
const char* _UriToPath(BString URI);
|
||||||
|
|
||||||
int32 fWindowIndex;
|
int32 fWindowIndex;
|
||||||
|
|
|
@ -75,6 +75,15 @@ Song::Path()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BString
|
||||||
|
Song::Type()
|
||||||
|
{
|
||||||
|
if (fType.IsEmpty())
|
||||||
|
BNode(fPath.Path()).ReadAttrString("BEOS:TYPE", &fType);
|
||||||
|
return fType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int64
|
int64
|
||||||
Song::Duration()
|
Song::Duration()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define SONG_H
|
#define SONG_H
|
||||||
|
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ public:
|
||||||
BBitmap* Cover();
|
BBitmap* Cover();
|
||||||
|
|
||||||
BPath Path();
|
BPath Path();
|
||||||
|
BString Type();
|
||||||
int64 Duration();
|
int64 Duration();
|
||||||
|
|
||||||
int operator ==(Song a)
|
int operator ==(Song a)
|
||||||
|
@ -60,6 +62,7 @@ private:
|
||||||
|
|
||||||
int64 fDuration;
|
int64 fDuration;
|
||||||
BPath fPath;
|
BPath fPath;
|
||||||
|
BString fType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SONG_H
|
#endif // SONG_H
|
||||||
|
|
Ŝarĝante…
Reference in New Issue