1 /* 2 * Controller.cpp - Media Player for the Haiku Operating System 3 * 4 * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * version 2 as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 * 19 */ 20 #include <Message.h> 21 #include <stdio.h> 22 #include <string.h> 23 24 #include "ControllerView.h" 25 #include "Controller.h" 26 #include "Playlist.h" 27 #include "Player.h" 28 29 ControllerView::ControllerView(BRect frame, Controller *ctrl, Playlist *pl, Player *p) 30 : TransportControlGroup(frame) 31 , fController(ctrl) 32 , fPlaylist(pl) 33 , fPlayer(p) 34 { 35 } 36 37 38 ControllerView::~ControllerView() 39 { 40 } 41 42 43 void 44 ControllerView::AttachedToWindow() 45 { 46 TransportControlGroup::AttachedToWindow(); 47 } 48 49 50 void 51 ControllerView::Draw(BRect updateRect) 52 { 53 TransportControlGroup::Draw(updateRect); 54 } 55 56 57 void 58 ControllerView::MessageReceived(BMessage *msg) 59 { 60 switch (msg->what) { 61 default: 62 TransportControlGroup::MessageReceived(msg); 63 } 64 } 65 66 // #pragma mark - 67 68 69 uint32 70 ControllerView::EnabledButtons() 71 { 72 return 0xffffffff; 73 } 74 75 76 void 77 ControllerView::TogglePlaying() 78 { 79 printf("ControllerView::TogglePlaying()\n"); 80 if (fController->IsPaused() || fController->IsStopped()) 81 fController->Play(); 82 else 83 fController->Pause(); 84 } 85 86 87 void 88 ControllerView::Stop() 89 { 90 printf("ControllerView::Stop()\n"); 91 fController->Stop(); 92 } 93 94 95 void 96 ControllerView::Rewind() 97 { 98 // TODO: make it so this function is called repeatedly 99 printf("ControllerView::Rewind()\n"); 100 } 101 102 103 void 104 ControllerView::Forward() 105 { 106 // TODO: make it so this function is called repeatedly 107 printf("ControllerView::Forward()\n"); 108 } 109 110 111 void 112 ControllerView::SkipBackward() 113 { 114 printf("ControllerView::SkipBackward()\n"); 115 entry_ref ref; 116 if (fPlaylist->PrevRef(&ref) == B_OK) { 117 printf("prev ref: %s\n", ref.name); 118 fPlayer->OpenFile(ref); 119 } 120 } 121 122 123 void 124 ControllerView::SkipForward() 125 { 126 printf("ControllerView::SkipForward()\n"); 127 entry_ref ref; 128 if (fPlaylist->NextRef(&ref) == B_OK) { 129 printf("next ref: %s\n", ref.name); 130 fPlayer->OpenFile(ref); 131 } 132 } 133 134 135 void 136 ControllerView::VolumeChanged(float value) 137 { 138 printf("ControllerView::VolumeChanged(%.4f)\n", value); 139 fController->SetVolume(value); 140 } 141 142 143 void 144 ControllerView::ToggleMute() 145 { 146 printf("ControllerView::ToggleMute()\n"); 147 } 148 149 150 void 151 ControllerView::PositionChanged(float value) 152 { 153 printf("ControllerView::PositionChanged(%.2f)\n", value); 154 // 0.0 ... 1.0 155 fController->SetPosition(value); 156 } 157 158