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 ATTR_STRING_DURATION = 'drtn', 53 54 ATTR_INT32_TRACK = 'trck', 55 ATTR_INT32_YEAR = 'year', 56 ATTR_INT32_RATING = 'rtng' 57 } Attribute; 58 59 virtual status_t SetAttribute(const Attribute& attribute, 60 const BString& string) = 0; 61 virtual status_t GetAttribute(const Attribute& attribute, 62 BString& string) const = 0; 63 64 virtual status_t SetAttribute(const Attribute& attribute, 65 const int32& value) = 0; 66 virtual status_t GetAttribute(const Attribute& attribute, 67 int32& value) const = 0; 68 69 virtual status_t SetAttribute(const Attribute& attribute, 70 const int64& value) = 0; 71 virtual status_t GetAttribute(const Attribute& attribute, 72 int64& value) const = 0; 73 74 // convenience access to attributes 75 BString Name() const; 76 BString Author() const; 77 BString Album() const; 78 BString Title() const; 79 80 int32 TrackNumber() 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 TrackSupplier* CreateTrackSupplier() const = 0; 92 93 void SetPlaybackFailed(); 94 bool PlaybackFailed() const 95 { return fPlaybackFailed; } 96 97 // listener support 98 bool AddListener(Listener* listener); 99 void RemoveListener(Listener* listener); 100 101 protected: 102 void _NotifyListeners() const; 103 104 private: 105 BList fListeners; 106 bool fPlaybackFailed; 107 }; 108 109 typedef BReference<PlaylistItem> PlaylistItemRef; 110 111 #endif // PLAYLIST_ITEM_H 112