1 /* 2 * Copyright 2016, Dario Casalinuovo 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "UrlPlaylistItem.h" 8 9 #include <MediaFile.h> 10 11 #include "MediaFileTrackSupplier.h" 12 13 14 UrlPlaylistItem::UrlPlaylistItem(BUrl* url) 15 : 16 fUrl(url) 17 { 18 19 } 20 21 22 UrlPlaylistItem::UrlPlaylistItem(const UrlPlaylistItem& item) 23 { 24 fUrl = new BUrl(item.Url()->UrlString()); 25 } 26 27 28 UrlPlaylistItem::UrlPlaylistItem(const BMessage* archive) 29 { 30 } 31 32 33 UrlPlaylistItem::~UrlPlaylistItem() 34 { 35 delete fUrl; 36 } 37 38 39 PlaylistItem* 40 UrlPlaylistItem::Clone() const 41 { 42 return new UrlPlaylistItem(new BUrl(fUrl->UrlString())); 43 } 44 45 46 BArchivable* 47 UrlPlaylistItem::Instantiate(BMessage* archive) 48 { 49 return new UrlPlaylistItem(archive); 50 } 51 52 53 status_t 54 UrlPlaylistItem::Archive(BMessage* into, bool deep) const 55 { 56 return B_ERROR; 57 } 58 59 60 status_t 61 UrlPlaylistItem::SetAttribute(const Attribute& attribute, const BString& string) 62 { 63 return B_ERROR; 64 } 65 66 67 status_t 68 UrlPlaylistItem::GetAttribute(const Attribute& attribute, BString& string) const 69 { 70 return B_ERROR; 71 } 72 73 74 status_t 75 UrlPlaylistItem::SetAttribute(const Attribute& attribute, const int32& value) 76 { 77 return B_ERROR; 78 } 79 80 81 status_t 82 UrlPlaylistItem::GetAttribute(const Attribute& attribute, int32& value) const 83 { 84 return B_ERROR; 85 } 86 87 88 status_t 89 UrlPlaylistItem::SetAttribute(const Attribute& attribute, const int64& value) 90 { 91 return B_ERROR; 92 } 93 94 95 status_t 96 UrlPlaylistItem::GetAttribute(const Attribute& attribute, int64& value) const 97 { 98 return B_ERROR; 99 } 100 101 102 BString 103 UrlPlaylistItem::LocationURI() const 104 { 105 return fUrl->UrlString(); 106 } 107 108 109 status_t 110 UrlPlaylistItem::GetIcon(BBitmap* bitmap, icon_size iconSize) const 111 { 112 return B_ERROR; 113 } 114 115 116 status_t 117 UrlPlaylistItem::MoveIntoTrash() 118 { 119 return B_ERROR; 120 } 121 122 123 status_t 124 UrlPlaylistItem::RestoreFromTrash() 125 { 126 return B_ERROR; 127 } 128 129 130 TrackSupplier* 131 UrlPlaylistItem::CreateTrackSupplier() const 132 { 133 MediaFileTrackSupplier* supplier 134 = new(std::nothrow) MediaFileTrackSupplier(); 135 if (supplier == NULL) 136 return NULL; 137 138 BMediaFile* mediaFile = new(std::nothrow) BMediaFile(fUrl); 139 if (mediaFile == NULL) { 140 delete supplier; 141 return NULL; 142 } 143 if (supplier->AddMediaFile(mediaFile) != B_OK) 144 delete mediaFile; 145 146 return supplier; 147 } 148 149 150 BUrl* 151 UrlPlaylistItem::Url() const 152 { 153 return fUrl; 154 } 155