1 /* 2 * Copyright 2007, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #include "ControllerObserver.h" 10 11 #include <Message.h> 12 13 14 ControllerObserver::ControllerObserver(BHandler* target, uint32 observeFlags) 15 : Controller::Listener() 16 , AbstractLOAdapter(target) 17 , fObserveFlags(observeFlags) 18 { 19 } 20 21 22 ControllerObserver::~ControllerObserver() 23 { 24 } 25 26 27 void 28 ControllerObserver::FileFinished() 29 { 30 if (!(fObserveFlags & OBSERVE_FILE_CHANGES)) 31 return; 32 33 BMessage message(MSG_CONTROLLER_FILE_FINISHED); 34 35 DeliverMessage(message); 36 } 37 38 39 void 40 ControllerObserver::FileChanged() 41 { 42 if (!(fObserveFlags & OBSERVE_FILE_CHANGES)) 43 return; 44 45 BMessage message(MSG_CONTROLLER_FILE_CHANGED); 46 47 DeliverMessage(message); 48 } 49 50 51 void 52 ControllerObserver::VideoTrackChanged(int32 index) 53 { 54 if (!(fObserveFlags & OBSERVE_TRACK_CHANGES)) 55 return; 56 57 BMessage message(MSG_CONTROLLER_VIDEO_TRACK_CHANGED); 58 message.AddInt32("index", index); 59 60 DeliverMessage(message); 61 } 62 63 64 void 65 ControllerObserver::AudioTrackChanged(int32 index) 66 { 67 if (!(fObserveFlags & OBSERVE_TRACK_CHANGES)) 68 return; 69 70 BMessage message(MSG_CONTROLLER_AUDIO_TRACK_CHANGED); 71 message.AddInt32("index", index); 72 73 DeliverMessage(message); 74 } 75 76 77 void 78 ControllerObserver::VideoStatsChanged() 79 { 80 if (!(fObserveFlags & OBSERVE_STAT_CHANGES)) 81 return; 82 83 BMessage message(MSG_CONTROLLER_VIDEO_STATS_CHANGED); 84 85 DeliverMessage(message); 86 } 87 88 89 void 90 ControllerObserver::AudioStatsChanged() 91 { 92 if (!(fObserveFlags & OBSERVE_STAT_CHANGES)) 93 return; 94 95 BMessage message(MSG_CONTROLLER_AUDIO_STATS_CHANGED); 96 97 DeliverMessage(message); 98 } 99 100 101 void 102 ControllerObserver::PlaybackStateChanged(uint32 state) 103 { 104 if (!(fObserveFlags & OBSERVE_PLAYBACK_STATE_CHANGES)) 105 return; 106 107 BMessage message(MSG_CONTROLLER_PLAYBACK_STATE_CHANGED); 108 message.AddInt32("state", state); 109 110 DeliverMessage(message); 111 } 112 113 114 void 115 ControllerObserver::PositionChanged(float position) 116 { 117 if (!(fObserveFlags & OBSERVE_POSITION_CHANGES)) 118 return; 119 120 BMessage message(MSG_CONTROLLER_POSITION_CHANGED); 121 message.AddFloat("position", position); 122 123 DeliverMessage(message); 124 } 125 126 127 void 128 ControllerObserver::VolumeChanged(float volume) 129 { 130 if (!(fObserveFlags & OBSERVE_VOLUME_CHANGES)) 131 return; 132 133 BMessage message(MSG_CONTROLLER_VOLUME_CHANGED); 134 message.AddFloat("volume", volume); 135 136 DeliverMessage(message); 137 } 138 139 140