Changeset 277 for CoolAudio/Systems
- Timestamp:
- Oct 4, 2011, 1:52:48 PM (13 years ago)
- Location:
- CoolAudio/Systems
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.