Ejemplo n.º 1
0
void
PlayMediaFile(const char* media_type, const char* media_name)
{
	entry_ref ref;
	if (BMediaFiles().GetRefFor(media_type, media_name, &ref) != B_OK
		|| !BEntry(&ref).Exists())
		return;

	MediaFilePlayer* player = list.EachElement(FindMediaFilePlayer,
		(void*)media_name);

	if (player != NULL) {
		if (*(player->Ref()) == ref) {
			player->Restart();
			return;
		}

		list.RemoveItem(player);
		delete player;
		player = NULL;
	}

	if (player == NULL) {
		player = new MediaFilePlayer(media_type, media_name, &ref);
		if (player->InitCheck() == B_OK)
			list.AddItem(player);
		else
			delete player;
	}
}
Ejemplo n.º 2
0
static const entry_ref*
AddOneUniqueDocumentType(const entry_ref* ref, void* castToList)
{
	BObjectList<BString>* list = (BObjectList<BString>*)castToList;

	BEntry entry(ref, true);
		// traverse symlinks

	// get this documents type
	char type[B_MIME_TYPE_LENGTH];
	BFile file(&entry, O_RDONLY);
	if (file.InitCheck() != B_OK)
		return 0;

	BNodeInfo info(&file);
	if (info.GetType(type) != B_OK)
		return 0;

	if (list->EachElement(FindOne, &type))
		// type already in list, bail
		return 0;

	// add type to list
	list->AddItem(new BString(type));

	return 0;
}