- Timestamp:
- Oct 4, 2011, 1:18:33 PM (13 years ago)
- Location:
- CoolAudio
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolAudio/CoolAudio.lpk
r275 r276 12 12 <Debugging> 13 13 <GenerateDebugInfo Value="True"/> 14 <DebugInfoType Value="dsAuto"/>15 14 </Debugging> 16 15 </Linking> … … 62 61 </Files> 63 62 <Type Value="RunAndDesignTime"/> 64 <RequiredPkgs Count=" 1">63 <RequiredPkgs Count="2"> 65 64 <Item1> 65 <PackageName Value="LCL"/> 66 </Item1> 67 <Item2> 66 68 <PackageName Value="FCL"/> 67 </Item 1>69 </Item2> 68 70 </RequiredPkgs> 69 71 <UsageOptions> -
CoolAudio/Demo
- Property svn:ignore
-
old new 2 2 11-seal-amazing.mp3 3 3 lib 4 Demo.exe
-
- Property svn:ignore
-
CoolAudio/Demo/Demo.lpi
r275 r276 38 38 </Item2> 39 39 </RequiredPackages> 40 <Units Count=" 10">40 <Units Count="20"> 41 41 <Unit0> 42 42 <Filename Value="Demo.lpr"/> 43 43 <IsPartOfProject Value="True"/> 44 44 <UnitName Value="Demo"/> 45 <UsageCount Value="2 1"/>45 <UsageCount Value="28"/> 46 46 </Unit0> 47 47 <Unit1> … … 51 51 <ResourceBaseClass Value="Form"/> 52 52 <UnitName Value="UMainForm"/> 53 <IsVisibleTab Value="True"/>54 53 <EditorIndex Value="0"/> 55 54 <WindowIndex Value="0"/> 56 <TopLine Value=" 1"/>57 <CursorPos X=" 25" Y="9"/>58 <UsageCount Value="2 1"/>55 <TopLine Value="58"/> 56 <CursorPos X="66" Y="65"/> 57 <UsageCount Value="28"/> 59 58 <Loaded Value="True"/> 60 59 <LoadedDesigner Value="True"/> … … 63 62 <Filename Value="../UCoolAudio.pas"/> 64 63 <UnitName Value="UCoolAudio"/> 65 <EditorIndex Value="1"/> 66 <WindowIndex Value="0"/> 67 <TopLine Value="1"/> 68 <CursorPos X="1" Y="11"/> 69 <UsageCount Value="10"/> 70 <Loaded Value="True"/> 64 <WindowIndex Value="0"/> 65 <TopLine Value="1"/> 66 <CursorPos X="34" Y="6"/> 67 <UsageCount Value="10"/> 71 68 </Unit2> 72 69 <Unit3> 73 70 <Filename Value="../Systems/UAudioSystemFMOD.pas"/> 74 71 <UnitName Value="UAudioSystemFMOD"/> 75 <EditorIndex Value=" 5"/>76 <WindowIndex Value="0"/> 77 <TopLine Value="1"/> 78 <CursorPos X=" 46" Y="11"/>79 <UsageCount Value="1 0"/>72 <EditorIndex Value="6"/> 73 <WindowIndex Value="0"/> 74 <TopLine Value="1"/> 75 <CursorPos X="20" Y="111"/> 76 <UsageCount Value="13"/> 80 77 <Loaded Value="True"/> 81 78 </Unit3> … … 83 80 <Filename Value="../UPlaylist.pas"/> 84 81 <UnitName Value="UPlaylist"/> 85 <EditorIndex Value="7"/>86 82 <WindowIndex Value="0"/> 87 83 <TopLine Value="1"/> 88 84 <CursorPos X="29" Y="8"/> 89 <UsageCount Value="20"/> 90 <Loaded Value="True"/> 85 <UsageCount Value="22"/> 91 86 </Unit4> 92 87 <Unit5> 93 88 <Filename Value="../fmodintf/fmoddyn.pas"/> 94 89 <UnitName Value="fmoddyn"/> 95 <EditorIndex Value="8"/>96 90 <WindowIndex Value="0"/> 97 91 <TopLine Value="46"/> 98 92 <CursorPos X="10" Y="63"/> 99 <UsageCount Value="10"/> 100 <Loaded Value="True"/> 93 <UsageCount Value="12"/> 101 94 </Unit5> 102 95 <Unit6> 103 96 <Filename Value="../fmodintf/fmodtypes.pas"/> 104 97 <UnitName Value="fmodtypes"/> 105 <EditorIndex Value="6"/>106 98 <WindowIndex Value="0"/> 107 99 <TopLine Value="158"/> 108 100 <CursorPos X="43" Y="178"/> 109 <UsageCount Value="10"/> 110 <Loaded Value="True"/> 101 <UsageCount Value="12"/> 111 102 </Unit6> 112 103 <Unit7> 113 104 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 114 105 <UnitName Value="UAudioSystemMPlayer"/> 115 <EditorIndex Value="4"/> 116 <WindowIndex Value="0"/> 117 <TopLine Value="1"/> 118 <CursorPos X="34" Y="8"/> 119 <UsageCount Value="10"/> 106 <IsVisibleTab Value="True"/> 107 <EditorIndex Value="3"/> 108 <WindowIndex Value="0"/> 109 <TopLine Value="258"/> 110 <CursorPos X="8" Y="260"/> 111 <UsageCount Value="13"/> 120 112 <Loaded Value="True"/> 121 113 </Unit7> … … 123 115 <Filename Value="../CoolAudio.pas"/> 124 116 <UnitName Value="CoolAudio"/> 125 <EditorIndex Value="2"/>126 117 <WindowIndex Value="0"/> 127 118 <TopLine Value="1"/> 128 119 <CursorPos X="1" Y="1"/> 129 120 <UsageCount Value="10"/> 130 <Loaded Value="True"/>131 121 </Unit8> 132 122 <Unit9> 133 123 <Filename Value="../Systems/UAudioSystem.pas"/> 134 124 <UnitName Value="UAudioSystem"/> 135 <EditorIndex Value=" 3"/>136 <WindowIndex Value="0"/> 137 <TopLine Value=" 48"/>138 <CursorPos X=" 1" Y="81"/>139 <UsageCount Value="2 0"/>125 <EditorIndex Value="2"/> 126 <WindowIndex Value="0"/> 127 <TopLine Value="70"/> 128 <CursorPos X="32" Y="82"/> 129 <UsageCount Value="23"/> 140 130 <Loaded Value="True"/> 141 131 </Unit9> 132 <Unit10> 133 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/lcl/stdctrls.pp"/> 134 <UnitName Value="StdCtrls"/> 135 <WindowIndex Value="0"/> 136 <TopLine Value="1046"/> 137 <CursorPos X="17" Y="1067"/> 138 <UsageCount Value="10"/> 139 </Unit10> 140 <Unit11> 141 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/lcl/controls.pp"/> 142 <UnitName Value="Controls"/> 143 <EditorIndex Value="1"/> 144 <WindowIndex Value="0"/> 145 <TopLine Value="2427"/> 146 <CursorPos X="24" Y="2429"/> 147 <UsageCount Value="10"/> 148 <Loaded Value="True"/> 149 </Unit11> 150 <Unit12> 151 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/lcl/lclclasses.pp"/> 152 <UnitName Value="LCLClasses"/> 153 <WindowIndex Value="0"/> 154 <TopLine Value="38"/> 155 <CursorPos X="32" Y="50"/> 156 <UsageCount Value="10"/> 157 </Unit12> 158 <Unit13> 159 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/lcl/widgetset/wslclclasses.pp"/> 160 <UnitName Value="WSLCLClasses"/> 161 <WindowIndex Value="0"/> 162 <TopLine Value="120"/> 163 <CursorPos X="16" Y="131"/> 164 <UsageCount Value="10"/> 165 </Unit13> 166 <Unit14> 167 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/lcl/include/buttons.inc"/> 168 <WindowIndex Value="0"/> 169 <TopLine Value="26"/> 170 <CursorPos X="18" Y="28"/> 171 <UsageCount Value="10"/> 172 </Unit14> 173 <Unit15> 174 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/lcl/include/buttoncontrol.inc"/> 175 <WindowIndex Value="0"/> 176 <TopLine Value="65"/> 177 <CursorPos X="17" Y="67"/> 178 <UsageCount Value="10"/> 179 </Unit15> 180 <Unit16> 181 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/lcl/include/control.inc"/> 182 <WindowIndex Value="0"/> 183 <TopLine Value="4280"/> 184 <CursorPos X="19" Y="4283"/> 185 <UsageCount Value="10"/> 186 </Unit16> 187 <Unit17> 188 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/lcl/include/wincontrol.inc"/> 189 <WindowIndex Value="0"/> 190 <TopLine Value="6307"/> 191 <CursorPos X="17" Y="6320"/> 192 <UsageCount Value="10"/> 193 </Unit17> 194 <Unit18> 195 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/packages/fcl-process/src/process.pp"/> 196 <UnitName Value="process"/> 197 <EditorIndex Value="4"/> 198 <WindowIndex Value="0"/> 199 <TopLine Value="13"/> 200 <CursorPos X="21" Y="26"/> 201 <UsageCount Value="10"/> 202 <Loaded Value="True"/> 203 </Unit18> 204 <Unit19> 205 <Filename Value="../../../../Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/packages/libogcfpc/src/debug.pp"/> 206 <UnitName Value="debug"/> 207 <EditorIndex Value="5"/> 208 <WindowIndex Value="0"/> 209 <TopLine Value="1"/> 210 <CursorPos X="1" Y="1"/> 211 <UsageCount Value="10"/> 212 <Loaded Value="True"/> 213 </Unit19> 142 214 </Units> 143 <JumpHistory Count=" 13" HistoryIndex="12">215 <JumpHistory Count="30" HistoryIndex="29"> 144 216 <Position1> 145 <Filename Value="../ UCoolAudio.pas"/>146 <Caret Line="2 2" Column="75" TopLine="1"/>217 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 218 <Caret Line="232" Column="1" TopLine="212"/> 147 219 </Position1> 148 220 <Position2> 149 <Filename Value="../ UCoolAudio.pas"/>150 <Caret Line=" 55" Column="3" TopLine="37"/>221 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 222 <Caret Line="244" Column="42" TopLine="228"/> 151 223 </Position2> 152 224 <Position3> 153 <Filename Value="../ UCoolAudio.pas"/>154 <Caret Line=" 18" Column="60" TopLine="1"/>225 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 226 <Caret Line="239" Column="1" TopLine="228"/> 155 227 </Position3> 156 228 <Position4> 157 <Filename Value="../ UCoolAudio.pas"/>158 <Caret Line=" 56" Column="18" TopLine="37"/>229 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 230 <Caret Line="240" Column="1" TopLine="228"/> 159 231 </Position4> 160 232 <Position5> 161 <Filename Value="../ UCoolAudio.pas"/>162 <Caret Line=" 46" Column="33" TopLine="21"/>233 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 234 <Caret Line="241" Column="1" TopLine="228"/> 163 235 </Position5> 164 236 <Position6> 165 <Filename Value="../ UCoolAudio.pas"/>166 <Caret Line=" 56" Column="3" TopLine="45"/>237 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 238 <Caret Line="242" Column="1" TopLine="228"/> 167 239 </Position6> 168 240 <Position7> 169 <Filename Value="../ UCoolAudio.pas"/>170 <Caret Line=" 11" Column="11" TopLine="1"/>241 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 242 <Caret Line="243" Column="1" TopLine="228"/> 171 243 </Position7> 172 244 <Position8> 173 <Filename Value="../ UCoolAudio.pas"/>174 <Caret Line=" 19" Column="12" TopLine="1"/>245 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 246 <Caret Line="240" Column="12" TopLine="228"/> 175 247 </Position8> 176 248 <Position9> 177 <Filename Value="../ UCoolAudio.pas"/>178 <Caret Line="2 0" Column="34" TopLine="2"/>249 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 250 <Caret Line="219" Column="53" TopLine="203"/> 179 251 </Position9> 180 252 <Position10> 181 <Filename Value="../ UCoolAudio.pas"/>182 <Caret Line=" 1" Column="1" TopLine="1"/>253 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 254 <Caret Line="240" Column="1" TopLine="227"/> 183 255 </Position10> 184 256 <Position11> 185 <Filename Value="../ CoolAudio.pas"/>186 <Caret Line=" 1" Column="1" TopLine="1"/>257 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 258 <Caret Line="241" Column="1" TopLine="227"/> 187 259 </Position11> 188 260 <Position12> 189 <Filename Value="../ CoolAudio.pas"/>190 <Caret Line=" 19" Column="44" TopLine="1"/>261 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 262 <Caret Line="242" Column="1" TopLine="227"/> 191 263 </Position12> 192 264 <Position13> 193 <Filename Value=" UMainForm.pas"/>194 <Caret Line=" 46" Column="15" TopLine="37"/>265 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 266 <Caret Line="243" Column="1" TopLine="227"/> 195 267 </Position13> 268 <Position14> 269 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 270 <Caret Line="240" Column="12" TopLine="227"/> 271 </Position14> 272 <Position15> 273 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 274 <Caret Line="110" Column="37" TopLine="108"/> 275 </Position15> 276 <Position16> 277 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 278 <Caret Line="239" Column="1" TopLine="227"/> 279 </Position16> 280 <Position17> 281 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 282 <Caret Line="240" Column="1" TopLine="227"/> 283 </Position17> 284 <Position18> 285 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 286 <Caret Line="241" Column="1" TopLine="227"/> 287 </Position18> 288 <Position19> 289 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 290 <Caret Line="240" Column="10" TopLine="227"/> 291 </Position19> 292 <Position20> 293 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 294 <Caret Line="126" Column="50" TopLine="108"/> 295 </Position20> 296 <Position21> 297 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 298 <Caret Line="230" Column="1" TopLine="218"/> 299 </Position21> 300 <Position22> 301 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 302 <Caret Line="231" Column="1" TopLine="218"/> 303 </Position22> 304 <Position23> 305 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 306 <Caret Line="109" Column="1" TopLine="97"/> 307 </Position23> 308 <Position24> 309 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 310 <Caret Line="110" Column="1" TopLine="97"/> 311 </Position24> 312 <Position25> 313 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 314 <Caret Line="111" Column="1" TopLine="97"/> 315 </Position25> 316 <Position26> 317 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 318 <Caret Line="112" Column="1" TopLine="97"/> 319 </Position26> 320 <Position27> 321 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 322 <Caret Line="116" Column="1" TopLine="97"/> 323 </Position27> 324 <Position28> 325 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 326 <Caret Line="233" Column="45" TopLine="218"/> 327 </Position28> 328 <Position29> 329 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 330 <Caret Line="112" Column="45" TopLine="97"/> 331 </Position29> 332 <Position30> 333 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 334 <Caret Line="230" Column="1" TopLine="218"/> 335 </Position30> 196 336 </JumpHistory> 197 337 </ProjectOptions> … … 208 348 <Debugging> 209 349 <GenerateDebugInfo Value="True"/> 210 <DebugInfoType Value="dsAuto"/>211 350 </Debugging> 212 351 <Options> … … 221 360 </CompilerOptions> 222 361 <Debugging> 223 < BreakPoints Count="2">362 <Watches Count="1"> 224 363 <Item1> 225 <Kind Value="bpkSource"/> 226 <WatchScope Value="wpsLocal"/> 227 <WatchKind Value="wpkWrite"/> 228 <Source Value="../UFMODAudio.pas"/> 229 <Line Value="59"/> 364 <Expression Value="MPOptions"/> 230 365 </Item1> 231 <Item2> 232 <Kind Value="bpkSource"/> 233 <WatchScope Value="wpsLocal"/> 234 <WatchKind Value="wpkWrite"/> 235 <Source Value="../UFMODAudio.pas"/> 236 <Line Value="49"/> 237 </Item2> 238 </BreakPoints> 366 </Watches> 239 367 <Exceptions Count="3"> 240 368 <Item1> -
CoolAudio/Demo/UMainForm.lfm
r275 r276 1 1 object MainForm: TMainForm 2 Left = 4792 Left = 531 3 3 Height = 240 4 Top = 2495 Width = 3594 Top = 300 5 Width = 435 6 6 Caption = 'CoolAudio demo' 7 7 ClientHeight = 240 8 ClientWidth = 3598 ClientWidth = 435 9 9 OnCreate = FormCreate 10 10 OnDestroy = FormDestroy … … 14 14 Height = 21 15 15 Top = 12 16 Width = 26416 Width = 340 17 17 Anchors = [akTop, akLeft, akRight] 18 18 TabOrder = 0 19 Text = ' 11-seal-amazing.mp3'19 Text = 'h:\Projekty2\PascalClassLibrary\CoolAudio\Demo\4 Strings - Catch A Fall (Radio Edit).mp3' 20 20 end 21 21 object Button1: TButton 22 Left = 27722 Left = 353 23 23 Height = 25 24 24 Top = 12 … … 26 26 Anchors = [akTop, akRight] 27 27 Caption = 'Select...' 28 OnClick = Button1Click 28 29 TabOrder = 1 29 30 end … … 59 60 Height = 33 60 61 Top = 90 61 Width = 34162 Width = 417 62 63 Position = 0 63 64 Anchors = [akTop, akLeft, akRight] 64 65 TabOrder = 5 65 66 end 67 object OpenDialog1: TOpenDialog 68 Filter = 'Any file (*.*)|*.*|MP3 (*.mp3)|*.mp3|WAV (*.wav)|*.wav' 69 left = 296 70 top = 48 71 end 66 72 end -
CoolAudio/Demo/UMainForm.pas
r275 r276 19 19 ButtonPause: TButton; 20 20 Edit1: TEdit; 21 OpenDialog1: TOpenDialog; 21 22 TrackBar1: TTrackBar; 23 procedure Button1Click(Sender: TObject); 22 24 procedure ButtonPauseClick(Sender: TObject); 23 25 procedure ButtonPlayClick(Sender: TObject); … … 43 45 procedure TMainForm.FormCreate(Sender: TObject); 44 46 begin 45 AudioSystem := TFMODAudioSystem.Create; 46 Player := TFMODPlayer.Create; 47 AudioSystem := TAudioSystemMPlayer.Create; 48 TAudioSystemMPlayer(AudioSystem).Path := 'c:\Program Files\SMPlayer\mplayer\mplayer.exe'; 49 Player := TPlayerMPlayer.Create; 50 Player.AudioSystem := AudioSystem; 47 51 end; 48 52 … … 55 59 procedure TMainForm.ButtonPlayClick(Sender: TObject); 56 60 begin 61 Player.FileName := Edit1.Text; 57 62 Player.Play; 58 63 end; … … 68 73 end; 69 74 75 procedure TMainForm.Button1Click(Sender: TObject); 76 begin 77 if OpenDialog1.Execute then Edit1.Text := OpenDialog1.FileName; 78 end; 79 70 80 end. 71 81 -
CoolAudio/Systems/UAudioSystem.pas
r275 r276 15 15 { TAudioSystem } 16 16 17 TAudioSystem = class 17 TAudioSystem = class(TComponent) 18 18 protected 19 19 FOutputDriver: TOutputDriver; … … 27 27 { TPlayer } 28 28 29 TPlayer = class 29 TPlayer = class(TComponent) 30 30 private 31 31 protected 32 FFileName: string; 33 FAudioSystem: TAudioSystem; 32 34 FPlaying: Boolean; 33 35 function GetMuted: Boolean; virtual; abstract; … … 38 40 procedure SetPosition(AValue: TDateTime); virtual; abstract; 39 41 procedure SetVolume(AValue: Real); virtual; abstract; 42 procedure SetFileName(AValue: string); virtual; 40 43 public 41 44 procedure Play; virtual; abstract; … … 46 49 property Volume: Real read GetVolume write SetVolume; // 0..1 47 50 property Muted: Boolean read GetMuted write SetMuted; 51 property AudioSystem: TAudioSystem read FAudioSystem write FAudioSystem; 52 property FileName: string read FFileName write SetFileName; 48 53 constructor Create; virtual; 49 54 end; … … 56 61 57 62 { TPlayer } 63 64 procedure TPlayer.SetFileName(AValue: string); 65 begin 66 if AValue = FFileName then Exit; 67 FFileName := AValue; 68 end; 58 69 59 70 constructor TPlayer.Create; … … 72 83 constructor TAudioSystem.Create; 73 84 begin 74 85 {$IFDEF Windows} 86 FOutputDriver := omWin32; 87 {$ENDIF} 88 {$IFDEF Linux} 89 FOutputDriver := omAlsa; 90 {$ENDIF} 75 91 end; 76 92 -
CoolAudio/Systems/UAudioSystemFMOD.pas
r275 r276 10 10 type 11 11 12 { T FMODAudioSystem}12 { TAudioSystemFMOD } 13 13 14 T FMODAudioSystem= class(TAudioSystem)14 TAudioSystemFMOD = class(TAudioSystem) 15 15 private 16 16 procedure SetOutputMode(AValue: TOutputDriver); override; … … 20 20 end; 21 21 22 { T FMODPlayer}22 { TPlayerFMOD } 23 23 24 T FMODPlayer= class(TPlayer)24 TPlayerFMOD = class(TPlayer) 25 25 private 26 26 FHandle: PFSoundStream; … … 41 41 implementation 42 42 43 { T FMODAudioSystem}43 { TAudioSystemFMOD } 44 44 45 procedure T FMODAudioSystem.SetOutputMode(AValue: TOutputDriver);45 procedure TAudioSystemFMOD.SetOutputMode(AValue: TOutputDriver); 46 46 begin 47 47 inherited SetOutputMode(AValue); … … 56 56 end; 57 57 58 constructor T FMODAudioSystem.Create;58 constructor TAudioSystemFMOD.Create; 59 59 begin 60 60 inherited Create; … … 64 64 end; 65 65 66 destructor T FMODAudioSystem.Destroy;66 destructor TAudioSystemFMOD.Destroy; 67 67 begin 68 68 FMOD_Unload; … … 70 70 end; 71 71 72 { T FMODPlayer}72 { TPlayerFMOD } 73 73 74 function T FMODPlayer.GetLength: TDateTime;74 function TPlayerFMOD.GetLength: TDateTime; 75 75 begin 76 76 Result := FVolume; 77 77 end; 78 78 79 function T FMODPlayer.GetPosition: TDateTime;79 function TPlayerFMOD.GetPosition: TDateTime; 80 80 begin 81 81 82 82 end; 83 83 84 function T FMODPlayer.GetVolume: Real;84 function TPlayerFMOD.GetVolume: Real; 85 85 begin 86 86 Result := FSOUND_GetVolume(0) / 256; 87 87 end; 88 88 89 function T FMODPlayer.GetMuted: Boolean;89 function TPlayerFMOD.GetMuted: Boolean; 90 90 begin 91 91 Result := FSOUND_GetMute(0); 92 92 end; 93 93 94 procedure T FMODPlayer.SetPosition(AValue: TDateTime);94 procedure TPlayerFMOD.SetPosition(AValue: TDateTime); 95 95 begin 96 96 if FPlaying then FSOUND_Stream_SetPosition(FHandle, Trunc(AValue / OneMillisecond)); 97 97 end; 98 98 99 procedure T FMODPlayer.SetVolume(AValue: Real);99 procedure TPlayerFMOD.SetVolume(AValue: Real); 100 100 begin 101 101 FSOUND_SetVolume(0, Trunc(AValue * 256)); 102 102 end; 103 103 104 procedure T FMODPlayer.SetMuted(AValue: Boolean);104 procedure TPlayerFMOD.SetMuted(AValue: Boolean); 105 105 begin 106 106 FSOUND_SetMute(0, AValue) 107 107 end; 108 108 109 procedure T FMODPlayer.Play;109 procedure TPlayerFMOD.Play; 110 110 begin 111 111 //FHandle := FSOUND_Stream_Open(tmpp, FSOUND_NONBLOCKING, 0, 0); … … 113 113 end; 114 114 115 procedure T FMODPlayer.Pause;115 procedure TPlayerFMOD.Pause; 116 116 begin 117 117 if FPlaying then … … 119 119 end; 120 120 121 procedure T FMODPlayer.Stop;121 procedure TPlayerFMOD.Stop; 122 122 begin 123 123 if FPlaying then begin -
CoolAudio/Systems/UAudioSystemMPlayer.pas
r275 r276 6 6 7 7 uses 8 Classes, SysUtils, UAudioSystem; 8 Classes, SysUtils, UAudioSystem, Process, Math, Dialogs; 9 10 const 11 {$ifdef Unix} 12 MPlayerExecutableName = 'mplayer'; 13 {$endif} 14 {$ifdef Windows} 15 MPlayerExecutableName = 'mplayer.exe'; 16 {$endif} 9 17 10 18 type … … 13 21 TAudioSystemMPlayer = class(TAudioSystem) 14 22 private 23 FPath: string; 15 24 procedure SetOutputMode(AValue: TOutputDriver); override; 25 function FindPath: string; 16 26 public 17 27 constructor Create; override; 18 28 destructor Destroy; override; 29 property Path: string read FPath write FPath; 19 30 end; 20 31 … … 23 34 TPlayerMPlayer = class(TPlayer) 24 35 private 36 FProcess: TProcess; 37 FProcessActive: Boolean; 38 FPlaying: Boolean; 25 39 FVolume: Real; 40 function GetProcessOutput: string; 41 procedure SendCommand(Command: string); 26 42 function GetLength: TDateTime; override; 27 43 function GetPosition: TDateTime; override; … … 31 47 procedure SetVolume(AValue: Real); override; 32 48 procedure SetMuted(AValue: Boolean); override; 49 procedure SetFileName(AValue: string); override; 33 50 public 34 51 procedure Play; override; 35 52 procedure Pause; override; 36 53 procedure Stop; override; 37 end; 38 54 constructor Create; override; 55 destructor Destroy; override; 56 end; 57 58 resourcestring 59 SMPlayerNotFound = 'MPlayer executable not found. Make sure it is properly installed in binary path'; 60 SSendCommandException = 'Exception occured during sending command to MPlayer'; 61 SErrorReadingOutput = 'Exception while reading MPlayer output'; 62 SCantStopProcess = 'Can''t stop Mplayer process'; 39 63 40 64 implementation … … 47 71 end; 48 72 73 function TAudioSystemMPlayer.FindPath: string; 74 var 75 tmps: string; 76 tmppath: string; 77 I: Integer; 78 begin 79 Result := ''; 80 {$ifdef Darwin} 81 {$else} 82 // Searches for MPlayer in the PATH 83 tmps := GetEnvironmentVariable('PATH'); 84 repeat 85 I := pos(':', tmps); 86 if I = 0 then I := Length(tmps); 87 tmppath := IncludeTrailingPathDelimiter(Copy(tmps, 0, I - 1)) + MPlayerExecutableName; 88 if FileExists(tmppath) then Result := tmppath 89 else Delete(tmps, 1, I); 90 until (Length(tmps) <= 1) or (Result <> ''); 91 {$endif} 92 if Result = '' then raise Exception.Create(SMPlayerNotFound); 93 end; 94 49 95 constructor TAudioSystemMPlayer.Create; 50 96 begin 51 97 inherited Create; 98 FPath := ''; 52 99 end; 53 100 … … 59 106 { TPlayerMPlayer } 60 107 108 procedure TPlayerMPlayer.SendCommand(Command: string); 109 begin 110 Command := Command + LineEnding;// #10; // MPLayer always needs #10 as Lineending, no matter if win32 or linux 111 try 112 if FProcessActive then FProcess.Input.Write(Command[1], System.Length(Command)); 113 except 114 raise Exception.Create(SSendCommandException); 115 end; 116 end; 117 61 118 function TPlayerMPlayer.GetLength: TDateTime; 62 119 begin 63 Result:=inherited GetLength;64 120 end; 65 121 66 122 function TPlayerMPlayer.GetPosition: TDateTime; 67 begin 68 Result:=inherited GetPosition; 123 var 124 tmps: string; 125 I: Integer; 126 Time: Real; 127 begin 128 if FProcess.Running then begin 129 I := 0; 130 repeat 131 SendCommand('get_property time_pos'); 132 Sleep(8); 133 tmps := GetProcessOutput; 134 Inc(I); 135 until (Pos('time_pos', tmps) > 0) or (I >= 3); 136 I := LastDelimiter('=', tmps); 137 if I > 0 then begin 138 Time := StrToFloat(Copy(tmps, I + 1, System.Length(tmps))); 139 Time := Time * 1000; 140 Result := Round(Time); 141 end else Result := -1; 142 end else Result := -1; 69 143 end; 70 144 71 145 function TPlayerMPlayer.GetVolume: Real; 72 146 begin 73 Result:=inherited GetVolume;74 147 end; 75 148 76 149 function TPlayerMPlayer.GetMuted: Boolean; 77 begin 78 Result:=inherited GetMuted; 150 var 151 tmps, s: string; 152 I: Integer; 153 begin 154 if FPlaying and FProcess.Running then begin 155 repeat 156 SendCommand('get_property mute'); 157 Sleep(5); 158 tmps := GetProcessOutput; 159 until Pos('mute', tmps) > 0; 160 i := LastDelimiter('=', tmps); 161 if i > 0 then begin 162 s := Copy(tmps, i + 1, System.Length(tmps) - i); 163 Result := s = 'yes'; 164 end; 165 end; 79 166 end; 80 167 81 168 procedure TPlayerMPlayer.SetPosition(AValue: TDateTime); 82 169 begin 83 inherited SetPosition(AValue);84 170 end; 85 171 86 172 procedure TPlayerMPlayer.SetVolume(AValue: Real); 87 173 begin 88 inherited SetVolume(AValue); 174 if FVolume = AValue then Exit; 175 FVolume := AValue; 176 if FPlaying and FProcess.Running then begin 177 if AValue < 0 then AValue := 0; 178 if AValue > 1 then AValue := 1; 179 SendCommand('set_property volume ' + IntToStr(Round(AValue * 100)) + '/1'); 180 end; 89 181 end; 90 182 91 183 procedure TPlayerMPlayer.SetMuted(AValue: Boolean); 92 184 begin 93 inherited SetMuted(AValue); 185 if FPlaying and FProcess.Running then 186 SendCommand('mute'); 187 end; 188 189 procedure TPlayerMPlayer.SetFileName(AValue: string); 190 begin 191 inherited SetFileName(AValue); 192 end; 193 194 function IntTodB(I, Ref: Longint): Integer; 195 var 196 dB: Real; 197 begin 198 if I = 0 then db := 0.001 else dB := I; 199 dB := 20 * log10(dB / ref); 200 Result := Round(dB); 94 201 end; 95 202 96 203 procedure TPlayerMPlayer.Play; 97 begin 98 inherited Play; 204 var 205 MPOptions: String; 206 Vol: Real; 207 begin 208 if FPlaying then Stop; 209 //FProcess := TProcess.Create(nil); 210 MPOptions := '-slave -quiet -softvol'; 211 if AudioSystem.OutputMode = omAlsa then MPOptions := MPOptions + ' -ao alsa'; 212 if AudioSystem.OutputMode = omOSS then MPOptions := MPOptions + ' -ao oss'; 213 if AudioSystem.OutputMode = omWin32 then MPOptions := MPOptions + ' -ao win32'; 214 if AudioSystem.OutputMode = omDirectX then MPOptions := MPOptions + ' -ao dsound'; 215 216 //MPOptions := '-af volume=' + IntToStr(IntTodB(Round(FVolume * 100), 100)) + ' ' + MPOptions;// -volume xx only supported with patched mplayer; 217 218 FProcess.CommandLine := TAudioSystemMPlayer(AudioSystem).FPath + ' ' + MPOptions + ' "' + FFileName + '"'; 219 FProcess.Options := FProcess.Options + [poUsePipes, poDefaultErrorMode, poStderrToOutPut, poNoConsole]; 220 //InputBox('', '', FProcess.CommandLine); 221 FProcess.Execute; 222 223 if FProcess.Running then begin 224 FPlaying := True; 225 end; 99 226 end; 100 227 101 228 procedure TPlayerMPlayer.Pause; 102 229 begin 103 inherited Pause; 230 if FPlaying then begin 231 SendCommand('pause'); 232 Sleep(10); 233 //FPaused := not FPaused; 234 end; 104 235 end; 105 236 106 237 procedure TPlayerMPlayer.Stop; 107 238 begin 108 inherited Stop; 239 if FPlaying then begin 240 SendCommand('quit'); 241 Sleep(15); 242 if FProcess.Running then begin 243 Sleep(50); 244 if FProcess.Running then 245 if not FProcess.Terminate(0) then 246 raise Exception.Create(SCantStopProcess); 247 end; 248 end; 249 FPlaying := False; 250 end; 251 252 constructor TPlayerMPlayer.Create; 253 begin 254 inherited Create; 255 FProcess := TProcess.Create(nil); 256 end; 257 258 destructor TPlayerMPlayer.Destroy; 259 begin 260 Stop; 261 FProcess.Free; 262 inherited Destroy; 263 end; 264 265 function TPlayerMPlayer.GetProcessOutput: string; 266 var 267 AStringList: TStringList; 268 begin 269 try 270 AStringList:=TStringList.Create; 271 try 272 if FProcess.Running then AStringList.LoadFromStream(FProcess.Output); 273 if AStringList.Count > 0 then 274 Result := AStringList.Strings[0] 275 else Result := ''; 276 except 277 Result := ''; 278 raise Exception.Create(SErrorReadingOutput); 279 end; 280 finally 281 AStringList.Free; 282 end; 109 283 end; 110 284
Note:
See TracChangeset
for help on using the changeset viewer.