1 /* 2 * Copyright 2009 Stephan Aßmus <superstippi@gmx.de> 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef PLAYLIST_ITEM_H 6 #define PLAYLIST_ITEM_H 7 8 #include <Archivable.h> 9 #include <List.h> 10 #include <NodeInfo.h> 11 #include <Referenceable.h> 12 #include <String.h> 13 14 class BBitmap; 15 class BDataIO; 16 class BMediaFile; 17 class BMessage; 18 19 class PlaylistItem : public BArchivable, public Referenceable { 20 public: 21 class Listener { 22 public: 23 Listener(); 24 virtual ~Listener(); 25 26 virtual void ItemChanged(const PlaylistItem* item); 27 }; 28 29 public: 30 PlaylistItem(); 31 virtual ~PlaylistItem(); 32 33 virtual PlaylistItem* Clone() const = 0; 34 35 // archiving 36 virtual status_t Archive(BMessage* into, 37 bool deep = true) const = 0; 38 39 // attributes 40 typedef enum { 41 ATTR_STRING_NAME = 'name', 42 ATTR_STRING_KEYWORDS = 'kwrd', 43 44 ATTR_STRING_AUTHOR = 'auth', 45 ATTR_STRING_ALBUM = 'albm', 46 ATTR_STRING_TITLE = 'titl', 47 48 ATTR_INT32_TRACK = 'trck', 49 ATTR_INT32_YEAR = 'year', 50 ATTR_INT32_RATING = 'rtng', 51 ATTR_INT32_BIT_RATE = 'btrt', 52 53 ATTR_INT64_DURATION = 'drtn' 54 } Attribute; 55 56 virtual status_t SetAttribute(const Attribute& attribute, 57 const BString& string) = 0; 58 virtual status_t GetAttribute(const Attribute& attribute, 59 BString& string) const = 0; 60 61 virtual status_t SetAttribute(const Attribute& attribute, 62 const int32& value) = 0; 63 virtual status_t GetAttribute(const Attribute& attribute, 64 int32& value) const = 0; 65 66 virtual status_t SetAttribute(const Attribute& attribute, 67 const int64& value) = 0; 68 virtual status_t GetAttribute(const Attribute& attribute, 69 int64& value) const = 0; 70 71 // convenience access to attributes 72 BString Name() const; 73 BString Author() const; 74 BString Album() const; 75 BString Title() const; 76 77 int32 TrackNumber() const; 78 int32 BitRate() const; 79 80 bigtime_t Duration() const; 81 82 // methods 83 virtual BString LocationURI() const = 0; 84 virtual status_t GetIcon(BBitmap* bitmap, 85 icon_size iconSize) const = 0; 86 87 virtual status_t MoveIntoTrash() = 0; 88 virtual status_t RestoreFromTrash() = 0; 89 90 // playback 91 virtual BMediaFile* CreateMediaFile() const = 0; 92 93 // listener support 94 bool AddListener(Listener* listener); 95 void RemoveListener(Listener* listener); 96 97 protected: 98 void _NotifyListeners() const; 99 100 private: 101 BList fListeners; 102 }; 103 104 typedef Reference<PlaylistItem> PlaylistItemRef; 105 106 #endif // PLAYLIST_ITEM_H 107