xref: /haiku/src/apps/mediaplayer/playlist/PlaylistObserver.cpp (revision b6b0567fbd186f8ce8a0c90bdc7a7b5b4c649678)
1 /*
2  * Copyright 2007-2009 Stephan Aßmus <superstippi@gmx.de>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 
6 #include "PlaylistObserver.h"
7 
8 #include <Message.h>
9 
10 
11 PlaylistObserver::PlaylistObserver(BHandler* target)
12 	: Playlist::Listener()
13 	, AbstractLOAdapter(target)
14 {
15 }
16 
17 
18 PlaylistObserver::~PlaylistObserver()
19 {
20 }
21 
22 
23 void
24 PlaylistObserver::ItemAdded(PlaylistItem* item, int32 index)
25 {
26 	BMessage message(MSG_PLAYLIST_ITEM_ADDED);
27 	message.AddPointer("item", item);
28 	message.AddInt32("index", index);
29 
30 	DeliverMessage(message);
31 }
32 
33 
34 void
35 PlaylistObserver::ItemRemoved(int32 index)
36 {
37 	BMessage message(MSG_PLAYLIST_ITEM_REMOVED);
38 	message.AddInt32("index", index);
39 
40 	DeliverMessage(message);
41 }
42 
43 
44 void
45 PlaylistObserver::ItemsSorted()
46 {
47 	BMessage message(MSG_PLAYLIST_ITEMS_SORTED);
48 
49 	DeliverMessage(message);
50 }
51 
52 
53 void
54 PlaylistObserver::CurrentItemChanged(int32 newIndex)
55 {
56 	BMessage message(MSG_PLAYLIST_CURRENT_ITEM_CHANGED);
57 	message.AddInt32("index", newIndex);
58 
59 	DeliverMessage(message);
60 }
61 
62