- Timestamp:
- Oct 4, 2011, 1:52:48 PM (13 years ago)
- Location:
- CoolAudio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolAudio/Demo/Demo.lpi
r276 r277 43 43 <IsPartOfProject Value="True"/> 44 44 <UnitName Value="Demo"/> 45 <UsageCount Value="2 8"/>45 <UsageCount Value="29"/> 46 46 </Unit0> 47 47 <Unit1> … … 51 51 <ResourceBaseClass Value="Form"/> 52 52 <UnitName Value="UMainForm"/> 53 <IsVisibleTab Value="True"/> 53 54 <EditorIndex Value="0"/> 54 55 <WindowIndex Value="0"/> 55 <TopLine Value=" 58"/>56 <CursorPos X=" 66" Y="65"/>57 <UsageCount Value="2 8"/>56 <TopLine Value="1"/> 57 <CursorPos X="14" Y="3"/> 58 <UsageCount Value="29"/> 58 59 <Loaded Value="True"/> 59 60 <LoadedDesigner Value="True"/> … … 74 75 <TopLine Value="1"/> 75 76 <CursorPos X="20" Y="111"/> 76 <UsageCount Value="1 3"/>77 <UsageCount Value="14"/> 77 78 <Loaded Value="True"/> 78 79 </Unit3> … … 104 105 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 105 106 <UnitName Value="UAudioSystemMPlayer"/> 106 <IsVisibleTab Value="True"/>107 107 <EditorIndex Value="3"/> 108 108 <WindowIndex Value="0"/> 109 <TopLine Value="2 58"/>110 <CursorPos X=" 8" Y="260"/>111 <UsageCount Value="1 3"/>109 <TopLine Value="231"/> 110 <CursorPos X="1" Y="243"/> 111 <UsageCount Value="14"/> 112 112 <Loaded Value="True"/> 113 113 </Unit7> … … 125 125 <EditorIndex Value="2"/> 126 126 <WindowIndex Value="0"/> 127 <TopLine Value=" 70"/>128 <CursorPos X=" 32" Y="82"/>129 <UsageCount Value="2 3"/>127 <TopLine Value="17"/> 128 <CursorPos X="56" Y="29"/> 129 <UsageCount Value="24"/> 130 130 <Loaded Value="True"/> 131 131 </Unit9> … … 145 145 <TopLine Value="2427"/> 146 146 <CursorPos X="24" Y="2429"/> 147 <UsageCount Value="1 0"/>147 <UsageCount Value="11"/> 148 148 <Loaded Value="True"/> 149 149 </Unit11> … … 199 199 <TopLine Value="13"/> 200 200 <CursorPos X="21" Y="26"/> 201 <UsageCount Value="1 0"/>201 <UsageCount Value="11"/> 202 202 <Loaded Value="True"/> 203 203 </Unit18> … … 209 209 <TopLine Value="1"/> 210 210 <CursorPos X="1" Y="1"/> 211 <UsageCount Value="1 0"/>211 <UsageCount Value="11"/> 212 212 <Loaded Value="True"/> 213 213 </Unit19> … … 216 216 <Position1> 217 217 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 218 <Caret Line=" 232" Column="1" TopLine="212"/>218 <Caret Line="129" Column="1" TopLine="113"/> 219 219 </Position1> 220 220 <Position2> 221 221 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 222 <Caret Line=" 244" Column="42" TopLine="228"/>222 <Caret Line="130" Column="1" TopLine="113"/> 223 223 </Position2> 224 224 <Position3> 225 225 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 226 <Caret Line=" 239" Column="1" TopLine="228"/>226 <Caret Line="131" Column="1" TopLine="113"/> 227 227 </Position3> 228 228 <Position4> 229 229 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 230 <Caret Line=" 240" Column="1" TopLine="228"/>230 <Caret Line="128" Column="1" TopLine="113"/> 231 231 </Position4> 232 232 <Position5> 233 233 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 234 <Caret Line=" 241" Column="1" TopLine="228"/>234 <Caret Line="129" Column="1" TopLine="113"/> 235 235 </Position5> 236 236 <Position6> 237 237 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 238 <Caret Line=" 242" Column="1" TopLine="228"/>238 <Caret Line="130" Column="1" TopLine="113"/> 239 239 </Position6> 240 240 <Position7> 241 241 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 242 <Caret Line=" 243" Column="1" TopLine="228"/>242 <Caret Line="131" Column="1" TopLine="113"/> 243 243 </Position7> 244 244 <Position8> 245 245 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 246 <Caret Line=" 240" Column="12" TopLine="228"/>246 <Caret Line="132" Column="1" TopLine="113"/> 247 247 </Position8> 248 248 <Position9> 249 249 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 250 <Caret Line=" 219" Column="53" TopLine="203"/>250 <Caret Line="133" Column="1" TopLine="113"/> 251 251 </Position9> 252 252 <Position10> 253 253 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 254 <Caret Line=" 240" Column="1" TopLine="227"/>254 <Caret Line="134" Column="1" TopLine="114"/> 255 255 </Position10> 256 256 <Position11> 257 257 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 258 <Caret Line=" 241" Column="1" TopLine="227"/>258 <Caret Line="135" Column="1" TopLine="115"/> 259 259 </Position11> 260 260 <Position12> 261 261 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 262 <Caret Line=" 242" Column="1" TopLine="227"/>262 <Caret Line="136" Column="1" TopLine="116"/> 263 263 </Position12> 264 264 <Position13> 265 265 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 266 <Caret Line=" 243" Column="1" TopLine="227"/>266 <Caret Line="139" Column="1" TopLine="119"/> 267 267 </Position13> 268 268 <Position14> 269 <Filename Value=" ../Systems/UAudioSystemMPlayer.pas"/>270 <Caret Line=" 240" Column="12" TopLine="227"/>269 <Filename Value="UMainForm.pas"/> 270 <Caret Line="63" Column="1" TopLine="59"/> 271 271 </Position14> 272 272 <Position15> 273 <Filename Value=" ../Systems/UAudioSystemMPlayer.pas"/>274 <Caret Line=" 110" Column="37" TopLine="108"/>273 <Filename Value="UMainForm.pas"/> 274 <Caret Line="70" Column="1" TopLine="61"/> 275 275 </Position15> 276 276 <Position16> 277 <Filename Value=" ../Systems/UAudioSystemMPlayer.pas"/>278 <Caret Line=" 239" Column="1" TopLine="227"/>277 <Filename Value="UMainForm.pas"/> 278 <Caret Line="64" Column="10" TopLine="62"/> 279 279 </Position16> 280 280 <Position17> 281 <Filename Value=" ../Systems/UAudioSystemMPlayer.pas"/>282 <Caret Line=" 240" Column="1" TopLine="227"/>281 <Filename Value="UMainForm.pas"/> 282 <Caret Line="35" Column="19" TopLine="23"/> 283 283 </Position17> 284 284 <Position18> 285 <Filename Value="../Systems/UAudioSystem MPlayer.pas"/>286 <Caret Line=" 241" Column="1" TopLine="227"/>285 <Filename Value="../Systems/UAudioSystem.pas"/> 286 <Caret Line="54" Column="62" TopLine="33"/> 287 287 </Position18> 288 288 <Position19> 289 <Filename Value=" ../Systems/UAudioSystemMPlayer.pas"/>290 <Caret Line=" 240" Column="10" TopLine="227"/>289 <Filename Value="UMainForm.pas"/> 290 <Caret Line="35" Column="19" TopLine="23"/> 291 291 </Position19> 292 292 <Position20> 293 <Filename Value=" ../Systems/UAudioSystemMPlayer.pas"/>294 <Caret Line=" 126" Column="50" TopLine="108"/>293 <Filename Value="UMainForm.pas"/> 294 <Caret Line="64" Column="20" TopLine="52"/> 295 295 </Position20> 296 296 <Position21> 297 297 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 298 <Caret Line="2 30" Column="1" TopLine="218"/>298 <Caret Line="246" Column="16" TopLine="225"/> 299 299 </Position21> 300 300 <Position22> 301 301 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 302 <Caret Line="2 31" Column="1" TopLine="218"/>302 <Caret Line="245" Column="1" TopLine="225"/> 303 303 </Position22> 304 304 <Position23> 305 305 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 306 <Caret Line=" 109" Column="1" TopLine="97"/>306 <Caret Line="246" Column="1" TopLine="226"/> 307 307 </Position23> 308 308 <Position24> 309 309 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 310 <Caret Line=" 110" Column="1" TopLine="97"/>310 <Caret Line="248" Column="1" TopLine="228"/> 311 311 </Position24> 312 312 <Position25> 313 <Filename Value=" ../Systems/UAudioSystemMPlayer.pas"/>314 <Caret Line=" 111" Column="1" TopLine="97"/>313 <Filename Value="UMainForm.pas"/> 314 <Caret Line="64" Column="19" TopLine="50"/> 315 315 </Position25> 316 316 <Position26> 317 <Filename Value="../Systems/UAudioSystem MPlayer.pas"/>318 <Caret Line=" 112" Column="1" TopLine="97"/>317 <Filename Value="../Systems/UAudioSystem.pas"/> 318 <Caret Line="54" Column="41" TopLine="42"/> 319 319 </Position26> 320 320 <Position27> 321 321 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 322 <Caret Line=" 116" Column="1" TopLine="97"/>322 <Caret Line="36" Column="26" TopLine="29"/> 323 323 </Position27> 324 324 <Position28> 325 <Filename Value="../Systems/UAudioSystem MPlayer.pas"/>326 <Caret Line="2 33" Column="45" TopLine="218"/>325 <Filename Value="../Systems/UAudioSystem.pas"/> 326 <Caret Line="29" Column="56" TopLine="17"/> 327 327 </Position28> 328 328 <Position29> 329 329 <Filename Value="../Systems/UAudioSystemMPlayer.pas"/> 330 <Caret Line=" 112" Column="45" TopLine="97"/>330 <Caret Line="243" Column="1" TopLine="231"/> 331 331 </Position29> 332 332 <Position30> 333 <Filename Value=" ../Systems/UAudioSystemMPlayer.pas"/>334 <Caret Line=" 230" Column="1" TopLine="218"/>333 <Filename Value="UMainForm.pas"/> 334 <Caret Line="67" Column="35" TopLine="55"/> 335 335 </Position30> 336 336 </JumpHistory> -
CoolAudio/Demo/UMainForm.lfm
r276 r277 61 61 Top = 90 62 62 Width = 417 63 Max = 100 64 OnChange = TrackBar1Change 63 65 Position = 0 64 66 Anchors = [akTop, akLeft, akRight] … … 70 72 top = 48 71 73 end 74 object TimerPlayback: TTimer 75 OnTimer = TimerPlaybackTimer 76 left = 112 77 top = 144 78 end 72 79 end -
CoolAudio/Demo/UMainForm.pas
r276 r277 1 1 unit UMainForm; 2 2 3 {$mode objfpc}{$H+}3 {$mode Delphi}{$H+} 4 4 5 5 interface … … 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, UAudioSystem, UAudioSystemFMOD, UAudioSystemMPlayer;9 ComCtrls, ExtCtrls, UAudioSystem, UAudioSystemFMOD, UAudioSystemMPlayer; 10 10 11 11 type … … 20 20 Edit1: TEdit; 21 21 OpenDialog1: TOpenDialog; 22 TimerPlayback: TTimer; 22 23 TrackBar1: TTrackBar; 23 24 procedure Button1Click(Sender: TObject); … … 27 28 procedure FormCreate(Sender: TObject); 28 29 procedure FormDestroy(Sender: TObject); 30 procedure TimerPlaybackTimer(Sender: TObject); 31 procedure TrackBar1Change(Sender: TObject); 29 32 private 30 33 { private declarations } … … 57 60 end; 58 61 62 procedure TMainForm.TimerPlaybackTimer(Sender: TObject); 63 begin 64 if Player.Playing then begin 65 TrackBar1.OnChange := nil; 66 TrackBar1.Position := Trunc(Player.Position / Player.Length * TrackBar1.Max); 67 TrackBar1.OnChange := TrackBar1Change; 68 end; 69 end; 70 71 procedure TMainForm.TrackBar1Change(Sender: TObject); 72 begin 73 Player.Position := TrackBar1.Position / TrackBar1.Max * Player.Length; 74 end; 75 59 76 procedure TMainForm.ButtonPlayClick(Sender: TObject); 60 77 begin -
CoolAudio/Systems/UAudioSystem.pas
r276 r277 29 29 TPlayer = class(TComponent) 30 30 private 31 procedure SetPlaying(AValue: Boolean); 31 32 protected 32 33 FFileName: string; … … 51 52 property AudioSystem: TAudioSystem read FAudioSystem write FAudioSystem; 52 53 property FileName: string read FFileName write SetFileName; 54 property Playing: Boolean read FPlaying write SetPlaying; 53 55 constructor Create; virtual; 54 56 end; … … 61 63 62 64 { TPlayer } 65 66 procedure TPlayer.SetPlaying(AValue: Boolean); 67 begin 68 if FPlaying = AValue then Exit; 69 if AValue then Play else Stop; 70 end; 63 71 64 72 procedure TPlayer.SetFileName(AValue: string); -
CoolAudio/Systems/UAudioSystemMPlayer.pas
r276 r277 1 // MPlayer slave command list: http://www.mplayerhq.hu/DOCS/tech/slave.txt 2 1 3 unit UAudioSystemMPlayer; 2 4 … … 6 8 7 9 uses 8 Classes, SysUtils, UAudioSystem, Process, Math, Dialogs ;10 Classes, SysUtils, UAudioSystem, Process, Math, Dialogs, DateUtils; 9 11 10 12 const … … 35 37 private 36 38 FProcess: TProcess; 37 FProcessActive: Boolean;38 FPlaying: Boolean;39 39 FVolume: Real; 40 40 function GetProcessOutput: string; … … 108 108 procedure TPlayerMPlayer.SendCommand(Command: string); 109 109 begin 110 Command := Command + LineEnding;//#10; // MPLayer always needs #10 as Lineending, no matter if win32 or linux110 Command := Command + #10; // MPLayer always needs #10 as Lineending, no matter if win32 or linux 111 111 try 112 if FProcess Activethen FProcess.Input.Write(Command[1], System.Length(Command));112 if FProcess.Running then FProcess.Input.Write(Command[1], System.Length(Command)); 113 113 except 114 114 raise Exception.Create(SSendCommandException); … … 117 117 118 118 function TPlayerMPlayer.GetLength: TDateTime; 119 begin 119 var 120 tmps: string; 121 I: Integer; 122 Time: Real; 123 begin 124 if FPlaying and fProcess.Running then begin 125 repeat 126 SendCommand('get_time_length'); 127 Sleep(5); 128 tmps := GetProcessOutput; 129 until Pos('LENGTH', tmps) > 0; 130 I := LastDelimiter('=', tmps); 131 if I > 0 then begin 132 Tmps := StringReplace(Tmps, '.', ',', [rfReplaceAll]); 133 Time := StrToFloat(Copy(tmps, I + 1, System.Length(tmps))); 134 Result := Time * OneSecond; 135 end; 136 end; 120 137 end; 121 138 … … 136 153 I := LastDelimiter('=', tmps); 137 154 if I > 0 then begin 155 Tmps := StringReplace(Tmps, '.', ',', [rfReplaceAll]); 138 156 Time := StrToFloat(Copy(tmps, I + 1, System.Length(tmps))); 139 Time := Time * 1000; 140 Result := Round(Time); 157 Result := Time * OneSecond; 141 158 end else Result := -1; 142 159 end else Result := -1; … … 168 185 procedure TPlayerMPlayer.SetPosition(AValue: TDateTime); 169 186 begin 187 if FPlaying and FProcess.Running then begin 188 SendCommand('set_property time_pos ' + StringReplace(FloatToStr(AValue / OneSecond), ',', '.', [rfReplaceAll])); 189 end; 170 190 end; 171 191
Note:
See TracChangeset
for help on using the changeset viewer.