2 * Copyright 2007-2009, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
10 #include "ControllerObserver.h"
14 #include "PlaylistItem.h"
17 ControllerObserver::ControllerObserver(BHandler
* target
, uint32 observeFlags
)
19 AbstractLOAdapter(target
),
20 fObserveFlags(observeFlags
)
25 ControllerObserver::~ControllerObserver()
31 ControllerObserver::FileFinished()
33 if (!(fObserveFlags
& OBSERVE_FILE_CHANGES
))
36 BMessage
message(MSG_CONTROLLER_FILE_FINISHED
);
38 DeliverMessage(message
);
43 ControllerObserver::FileChanged(PlaylistItem
* item
, status_t result
)
45 if (!(fObserveFlags
& OBSERVE_FILE_CHANGES
))
48 PlaylistItemRef
reference(item
);
49 // pass the reference along with the message
51 BMessage
message(MSG_CONTROLLER_FILE_CHANGED
);
52 message
.AddInt32("result", result
);
53 if (message
.AddPointer("item", item
) == B_OK
)
56 DeliverMessage(message
);
61 ControllerObserver::VideoTrackChanged(int32 index
)
63 if (!(fObserveFlags
& OBSERVE_TRACK_CHANGES
))
66 BMessage
message(MSG_CONTROLLER_VIDEO_TRACK_CHANGED
);
67 message
.AddInt32("index", index
);
69 DeliverMessage(message
);
74 ControllerObserver::AudioTrackChanged(int32 index
)
76 if (!(fObserveFlags
& OBSERVE_TRACK_CHANGES
))
79 BMessage
message(MSG_CONTROLLER_AUDIO_TRACK_CHANGED
);
80 message
.AddInt32("index", index
);
82 DeliverMessage(message
);
87 ControllerObserver::SubTitleTrackChanged(int32 index
)
89 if (!(fObserveFlags
& OBSERVE_TRACK_CHANGES
))
92 BMessage
message(MSG_CONTROLLER_SUB_TITLE_TRACK_CHANGED
);
93 message
.AddInt32("index", index
);
95 DeliverMessage(message
);
100 ControllerObserver::VideoStatsChanged()
102 if (!(fObserveFlags
& OBSERVE_STAT_CHANGES
))
105 BMessage
message(MSG_CONTROLLER_VIDEO_STATS_CHANGED
);
107 DeliverMessage(message
);
112 ControllerObserver::AudioStatsChanged()
114 if (!(fObserveFlags
& OBSERVE_STAT_CHANGES
))
117 BMessage
message(MSG_CONTROLLER_AUDIO_STATS_CHANGED
);
119 DeliverMessage(message
);
124 ControllerObserver::PlaybackStateChanged(uint32 state
)
126 if (!(fObserveFlags
& OBSERVE_PLAYBACK_STATE_CHANGES
))
129 BMessage
message(MSG_CONTROLLER_PLAYBACK_STATE_CHANGED
);
130 message
.AddInt32("state", state
);
132 DeliverMessage(message
);
137 ControllerObserver::PositionChanged(float position
)
139 if (!(fObserveFlags
& OBSERVE_POSITION_CHANGES
))
142 BMessage
message(MSG_CONTROLLER_POSITION_CHANGED
);
143 message
.AddFloat("position", position
);
145 DeliverMessage(message
);
150 ControllerObserver::SeekHandled(int64 seekFrame
)
152 if (!(fObserveFlags
& OBSERVE_POSITION_CHANGES
))
155 BMessage
message(MSG_CONTROLLER_SEEK_HANDLED
);
156 message
.AddInt64("seek frame", seekFrame
);
158 DeliverMessage(message
);
163 ControllerObserver::VolumeChanged(float volume
)
165 if (!(fObserveFlags
& OBSERVE_VOLUME_CHANGES
))
168 BMessage
message(MSG_CONTROLLER_VOLUME_CHANGED
);
169 message
.AddFloat("volume", volume
);
171 DeliverMessage(message
);
176 ControllerObserver::MutedChanged(bool muted
)
178 if (!(fObserveFlags
& OBSERVE_VOLUME_CHANGES
))
181 BMessage
message(MSG_CONTROLLER_MUTED_CHANGED
);
182 message
.AddBool("muted", muted
);
184 DeliverMessage(message
);