1 /* 2 * Copyright 2009-2010 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 9 #include <Archivable.h> 10 #include <List.h> 11 #include <NodeInfo.h> 12 #include <Referenceable.h> 13 #include <String.h> 14 15 16 class BBitmap; 17 class BMessage; 18 class TrackSupplier; 19 20 21 class PlaylistItem : public BArchivable, public BReferenceable { 22 public: 23 class Listener { 24 public: 25 Listener(); 26 virtual ~Listener(); 27 28 virtual void ItemChanged(const PlaylistItem* item); 29 }; 30 31 public: 32 PlaylistItem(); 33 virtual ~PlaylistItem(); 34 35 virtual PlaylistItem* Clone() const = 0; 36 37 // archiving 38 virtual status_t Archive(BMessage* into, 39 bool deep = true) const = 0; 40 41 // attributes 42 typedef enum { 43 ATTR_STRING_NAME = 'name', 44 ATTR_STRING_KEYWORDS = 'kwrd', 45 46 ATTR_STRING_ARTIST = 'arst', 47 ATTR_STRING_AUTHOR = 'auth', 48 ATTR_STRING_ALBUM = 'albm', 49 ATTR_STRING_TITLE = 'titl', 50 ATTR_STRING_AUDIO_BITRATE = 'abtr', 51 ATTR_STRING_VIDEO_BITRATE = 'vbtr', 52 53 ATTR_INT32_TRACK = 'trck', 54 ATTR_INT32_YEAR = 'year', 55 ATTR_INT32_RATING = 'rtng', 56 57 ATTR_INT64_DURATION = 'drtn' 58 } Attribute; 59 60 virtual status_t SetAttribute(const Attribute& attribute, 61 const BString& string) = 0; 62 virtual status_t GetAttribute(const Attribute& attribute, 63 BString& string) const = 0; 64 65 virtual status_t SetAttribute(const Attribute& attribute, 66 const int32& value) = 0; 67 virtual status_t GetAttribute(const Attribute& attribute, 68 int32& value) const = 0; 69 70 virtual status_t SetAttribute(const Attribute& attribute, 71 const int64& value) = 0; 72 virtual status_t GetAttribute(const Attribute& attribute, 73 int64& value) const = 0; 74 75 // convenience access to attributes 76 BString Name() const; 77 BString Author() const; 78 BString Album() const; 79 BString Title() const; 80 81 int32 TrackNumber() const; 82 83 bigtime_t Duration(); 84 85 // methods 86 virtual BString LocationURI() const = 0; 87 virtual status_t GetIcon(BBitmap* bitmap, 88 icon_size iconSize) const = 0; 89 90 virtual status_t MoveIntoTrash() = 0; 91 virtual status_t RestoreFromTrash() = 0; 92 93 // playback 94 virtual TrackSupplier* CreateTrackSupplier() const = 0; 95 96 void SetPlaybackFailed(); 97 bool PlaybackFailed() const 98 { return fPlaybackFailed; } 99 100 // listener support 101 bool AddListener(Listener* listener); 102 void RemoveListener(Listener* listener); 103 104 protected: 105 void _NotifyListeners() const; 106 virtual bigtime_t _CalculateDuration() const; 107 108 private: 109 BList fListeners; 110 bool fPlaybackFailed; 111 }; 112 113 typedef BReference<PlaylistItem> PlaylistItemRef; 114 115 #endif // PLAYLIST_ITEM_H 116