Autor Beitrag
Naxor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

alle
delphi, C++, php, html, java, flash, XML
BeitragVerfasst: Sa 26.09.09 02:32 
Hi ich mache grad einen streamplayer für Online radios soweit funktioniert alles nur möschte ich einen Lautstärkenregler einbauen habt Ihr ne Idee wie ich das anstelle.

Hier der source

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Bass, ExtCtrls, sPanel, sSkinManager, sButton, shellapi, TrayIcon, acPNG,
  Menus, sSkinProvider, sScrollBar, ComCtrls, sLabel;

const
  WM_INFO_UPDATE = WM_USER + 101;

type

  TForm1 = class(TForm)
    Panel1: TPanel;
    sSkinManager1: TsSkinManager;
    sPanel1: TsPanel;
    sButton1: TsButton;
    sPanel2: TsPanel;
    Label4: TLabel;
    Label3: TLabel;
    sPanel3: TsPanel;
    ed_ProxyServer: TEdit;
    Label6: TLabel;
    Label5: TLabel;
    TrayIcon1: TTrayIcon;
    Image1: TImage;
    PopupMenu1: TPopupMenu;
    Beenden1: TMenuItem;
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Beenden2: TMenuItem;
    sButton2: TsButton;
    sButton3: TsButton;
    sButton4: TsButton;
    sButton5: TsButton;
    sound: TsScrollBar;
    sPanel4: TsPanel;
    sLabelFX1: TsLabelFX;
    sLabelFX2: TsLabelFX;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure cbDirectConnectionClick(Sender: TObject);
    procedure sButton1Click(Sender: TObject);
    procedure Beenden1Click(Sender: TObject);
    procedure Beenden2Click(Sender: TObject);
    procedure sButton4Click(Sender: TObject);
    procedure sButton5Click(Sender: TObject);
    procedure sButton2Click(Sender: TObject);
    procedure sButton3Click(Sender: TObject);

  private
    { Private declarations }

  public
    { Public declarations }
    procedure WndProc(var Msg: TMessage); override;


  end;

var
  Form1: TForm1;
  Proxy: array [0..99] of char; 
  cthread: DWORD = 0;
  chan: HSTREAM = 0;
  win: hwnd;
implementation

uses Unit2;

const
  urls: array[0..9] of string = ( // adresse ist nicht echt zum testen bitte eigne eintragen
  'http://www.onlineradio.net/radio.asx','http://www.onlineradio.net/radio.asx',  
    );

{$R *.dfm}

  { display error messages }

procedure Error(es: string);
begin
  MessageBox(win, PChar(es + #13#10 + '(error code: ' + IntToStr(BASS_ErrorGetCode) +
    ')'), nil, 0);
end;

{ update stream title from metadata }

procedure DoMeta();
var
  meta: PChar;
  p: Integer;
begin
  meta := BASS_ChannelGetTags(chan, BASS_TAG_META);
  if (meta <> nil) then
  begin
    p := Pos('StreamTitle=', meta);
    if (p = 0) then
      Exit;
    p := p + 13;
    SendMessage(win, WM_INFO_UPDATE, 7, DWORD(PChar(Copy(meta, p, Pos(';', meta) - p - 1))));
  end;
end;

procedure MetaSync(handle: HSYNC; channel, data, user: DWORD); stdcall;
begin
  DoMeta();
end;

procedure StatusProc(buffer: Pointer; len, user: DWORD); stdcall;
begin
  if (buffer <> nil) and (len = 0) then
    SendMessage(win, WM_INFO_UPDATE, 8, DWORD(PChar(buffer)));
end;

function OpenURL(url: PChar): Integer;
var
  icy: PChar;
  Len, Progress: DWORD;
begin
  Result := 0;
  BASS_StreamFree(chan); 
  progress := 0;
  SendMessage(win, WM_INFO_UPDATE, 0, 0);

  chan := BASS_StreamCreateURL(url, 0, BASS_STREAM_STATUS, @StatusProc, 0);
  if (chan = 0) then
  begin
    SendMessage(win, WM_INFO_UPDATE, 1, Bass_ErrorGetCode()); 
  end
  else
  begin
    repeat
      len := BASS_StreamGetFilePosition(chan, BASS_FILEPOS_END);
      if (len = DW_Error) then
        break; 
      progress := (BASS_StreamGetFilePosition(chan, BASS_FILEPOS_DOWNLOAD) -
        BASS_StreamGetFilePosition(chan, BASS_FILEPOS_CURRENT)) * 100 div len;
      SendMessage(win, WM_INFO_UPDATE, 2, progress); 

    until
      progress > 75;
    icy := BASS_ChannelGetTags(chan, BASS_TAG_ICY);
    if (icy = nil) then
      icy := BASS_ChannelGetTags(chan, BASS_TAG_HTTP); 
    if (icy <> nil) then
      while (icy^ <> #0) do
      begin
        if (Copy(icy, 1, 9) = 'icy-name:') then
          SendMessage(win, WM_INFO_UPDATE, 3, DWORD(PChar(Copy(icy, 10, MaxInt))))

        else if (Copy(icy, 1, 7) = 'icy-br:') then

          SendMessage(win, WM_INFO_UPDATE, 4, DWORD(PChar('bitrate: ' + Copy(icy, 8, MaxInt))));
        icy := icy + Length(icy) + 1;
      end;

    DoMeta();
    BASS_ChannelSetSync(chan, BASS_SYNC_META, 0, @MetaSync, 0);
    BASS_ChannelPlay(chan, FALSE);
  end;
  cthread := 0;
end;

                      
procedure TForm1.WndProc(var Msg: TMessage);
begin
  inherited;
  if Msg.Msg = WM_INFO_UPDATE then
    case msg.WParam of
      0:
        begin
          Label4.Caption := 'connecting...';
          Label3.Caption := '';
          Label5.Caption := '';
        end;
      1:
        begin
          Label4.Caption := 'not playing';
          //Error('Can''t play the stream');
         MessageBox(win, PChar('Can''t play the stream' + #13#10 + '(error code: ' +
            IntToStr(msg.LParam)+')'), nil, 0);

        end;
      2: Label4.Caption := Format('buffering... %d%%', [msg.LParam]);
      3: Label4.Caption := PChar(msg.LParam);
      4: Label5.Caption := PChar(msg.LParam);
      5: Label5.Caption := PChar(msg.LParam);
      6: Label3.Caption := PChar(msg.LParam);
      7: Label3.Caption := PChar(msg.LParam);
      8: Label5.Caption := PChar(msg.LParam);
    end;
end;                       

procedure TForm1.FormCreate(Sender: TObject);
begin
  win := handle;
  if (HIWORD(BASS_GetVersion) <> BASSVERSION) then
  begin
    MessageBox(0, 'An incorrect version of BASS.DLL was loaded', nil, MB_ICONERROR);
    Halt;
  end;
  if (not BASS_Init(-1, 44100, 0, Handle, nil)) then
  begin
    Error('Can''t initialize device');
    Halt;
  end;
  BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1); 
  BASS_SetConfig(BASS_CONFIG_NET_PREBUF, 0); instead
  BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, @proxy[0]); 

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  BASS_Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  ThreadId: Cardinal;
begin
  StrPCopy(proxy,ed_ProxyServer.Text); 
  if (cthread <> 0) then
    MessageBeep(0)
  else
    cthread := BeginThread(nil, 0, @OpenURL, PChar(urls[TButton(Sender).Tag]), 0, ThreadId);
end;

procedure TForm1.cbDirectConnectionClick(Sender: TObject);
begin
  if not TCheckbox(Sender).Checked then
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, @proxy[0]) 
  else
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, nil); 
end;

procedure TForm1.sButton1Click(Sender: TObject);
begin
  Form1.Close
  end;

procedure TForm1.Beenden1Click(Sender: TObject);
begin
 Form1.Close
end;

procedure TForm1.Beenden2Click(Sender: TObject);
begin
 Form1.Close
end;

procedure TForm1.sButton4Click(Sender: TObject);
var
  ThreadId: Cardinal;
begin
  StrPCopy(proxy,ed_ProxyServer.Text); 
  if (cthread <> 0) then
    MessageBeep(0)
  else
    cthread := BeginThread(nil, 0, @OpenURL, PChar(urls[TButton(Sender).Tag]), 0, ThreadId);
end;

procedure TForm1.sButton5Click(Sender: TObject);
begin
  if not TCheckbox(Sender).Checked then
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, @proxy[0]) 
  else
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, nil); 
end;

procedure TForm1.sButton2Click(Sender: TObject);
begin
    ShellExecute(Handle, 'open',
'http://www.onlineradio.net', nil, nil, SW_SHOWNORMAL);
end;

procedure TForm1.sButton3Click(Sender: TObject);
begin
 Form2.show
end;


end.



vielen dank für eure hilfe


Moderiert von user profile iconGausi: Topic aus Open Source Units verschoben am Sa 26.09.2009 um 10:50
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 26.09.09 09:53 
Natürlich funktioniert das. Das ist ja bis auf ein oder zwei kleine weitere Buttons genau der Bespielcode aus der Bass.dll-Demo zum Thema netradio.

Da du dich ja mit Threads und Messages auskennst, dürfte mein Player-Tutorial genau das richtige für dich sein. Da wird auch das mit der Lautstärke erklärt. :D

_________________
We are, we were and will not be.
Naxor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

alle
delphi, C++, php, html, java, flash, XML
BeitragVerfasst: Sa 26.09.09 11:55 
OK habe es hin bekommen nun habe ich das Problem wenn ich den palyer auf einem anderem rechner benutze springt die Antivirus programme an und löschen diese gleich wieder oder setzen diese in quarantäne wie kann ich dieses beheben
Naxor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

alle
delphi, C++, php, html, java, flash, XML
BeitragVerfasst: Fr 02.10.09 17:11 
Ich versuche verzweifelt einen Lautstärke Regler einzubauen aber Irgendwie Funkst das nicht


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.VolumeScrollbarScroll(Sender: TObject;
  ScrollCode: TScrollCode; var ScrollPos: Integer);
begin         
  Form1.Volume // fehler wird an dieser Position angezeig \\:= (100 - Scrollpos) / 100;
end;


Bitte kann mir jemand Helfen habe alles möglich versucht und vieles ausprobiert was hier als lösung angeboten wird aber alles Funkst nicht...

bitte um hilfe
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 02.10.09 17:41 
Im Posting davor hattest du geschrieben, dass du es hinbekommen hast - warum geht es jetzt nicht mehr?

Hat denn deine Form eine Eigenschaft Volume, die du da verändern willst? Oder ist Volume ein Integer, und man müsste Div anstelle von / benutzen (oder das Ergebnis mit Round runden)?

_________________
We are, we were and will not be.
Naxor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

alle
delphi, C++, php, html, java, flash, XML
BeitragVerfasst: Fr 02.10.09 17:47 
user profile iconGausi hat folgendes geschrieben Zum zitierten Posting springen:
Im Posting davor hattest du geschrieben, dass du es hinbekommen hast - warum geht es jetzt nicht mehr?

Hat denn deine Form eine Eigenschaft Volume, die du da verändern willst? Oder ist Volume ein Integer, und man müsste Div anstelle von / benutzen (oder das Ergebnis mit Round runden)?


ja in dem ich den regler in einer neuen unit eingefügt habe aber der regler soll direckt auf dem player eingebaut werden außerdem musste ich all meine Daten löschen wegen dem Virus da es trotz der lösungen immer wieder aufgetaucht ist habe delphi jetzt auf einem anderem rechner Ohne internet anschluss damit sowas nicht nochmal passiert
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 02.10.09 18:01 
Ich habe kein Wort von dem verstanden, was du da grade geschrieben hast. Oder zumindest nicht, was das zur Problemlösung beitragen könnte. :gruebel:

_________________
We are, we were and will not be.
Naxor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

alle
delphi, C++, php, html, java, flash, XML
BeitragVerfasst: Fr 02.10.09 18:24 
ok versuche es mal zu vereinfachen...


Ich habe bei dem erstem Player einen button eingesetz der zu einem anderem Program verlinkt ist der einen Regler Öffnet um die Lautstärke zu rägeln sprich ein extra programm.. dies habe ich leder nicht mehr und will es auch auf dieser weise nicht machen...

Ich möschte direkt in dem player einen Lautstärkeregler einbauen... der nur die Lautstärke von dem player regelt wie bei einem mediaplayer oder mp3 player nur leider funkst das ganze nicht weil wenn ich das so mache wie in einigen beispielen gezeigt wird nicht geht bzw immer nen error kommt bzw das er es nicht ausführeen kann

daher bitte ich euch um Hilfe..

Könnte mir jemand nen beispiel geben oder nen tipp wie ich das einbauen kann ich wäre sehr dankbar dafür..

MFG Naxor
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 02.10.09 18:28 
Einen Link zu einem Tutorial habe ich schon gepostet.

Wenn du jetzt auch noch sagst, was du getan hast, wie dein Code aussieht und was das für ein Fehler ist, könnte man dir auch helfen...

_________________
We are, we were and will not be.
Naxor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

alle
delphi, C++, php, html, java, flash, XML
BeitragVerfasst: Fr 02.10.09 18:56 
Habe versucht nach deinem Totorial zu gehen

Hier der quelltext und ja es ist netradio von Bass

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Bass, ExtCtrls, sSkinManager, shellapi, sPanel, sButton, sScrollBar,
  PngImage1;

const
  WM_INFO_UPDATE = WM_USER + 101;

type

  TForm1 = class(TForm)
    Panel1: TPanel;
    sPanel1: TsPanel;
    sPanel2: TsPanel;
    sPanel3: TsPanel;
    sPanel4: TsPanel;
    ed_ProxyServer: TEdit;
    Label6: TLabel;
    Label4: TLabel;
    Label3: TLabel;
    Label5: TLabel;
    sSkinManager1: TsSkinManager;
    sButton1: TsButton;
    sPanel5: TsPanel;
    sButton2: TsButton;
    sButton3: TsButton;
    sButton4: TsButton;
    Image1: TImage;
    VolumeScrollbar: TsScrollBar;
    sSkinManager2: TsSkinManager;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure cbDirectConnectionClick(Sender: TObject);
    procedure sButton1Click(Sender: TObject);
    procedure sButton2Click(Sender: TObject);
    procedure sButton3Click(Sender: TObject);
    procedure sButton4Click(Sender: TObject);
    procedure VolumeScrollbarScroll(Sender: TObject;
      ScrollCode: TScrollCode; var ScrollPos: Integer);
  private
    { Private declarations }

  public
    { Public declarations }
    procedure WndProc(var Msg: TMessage); override;
  end;

var
  Form1: TForm1;
  bassvolume: Tbassvolume;
  Proxy: array [0..99] of char; //proxy server
  cthread: DWORD = 0;
  chan: HSTREAM = 0;
  win: hwnd;
  bassvolume: Tbassvolume;
implementation

uses Unit2;

const
  urls: array[0..9] of string = ( // preset stream URLs
  'http://localhost/radio.asx','http://localhost/radio.asx'
    );

{$R *.dfm}

  { display error messages }

procedure Error(es: string);
begin
  MessageBox(win, PChar(es + #13#10 + '(error code: ' + IntToStr(BASS_ErrorGetCode) +
    ')'), nil, 0);
end;

{ update stream title from metadata }

procedure TForm1.VolumeScrollbarScroll(Sender: TObject;
  ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
  bassvolume.Volume := (100 - Scrollpos) / 100;
end;

procedure MetaSync(handle: HSYNC; channel, data, user: DWORD); stdcall;
begin
  DoMeta();
end;

procedure StatusProc(buffer: Pointer; len, user: DWORD); stdcall;
begin
  if (buffer <> nil) and (len = 0) then
    SendMessage(win, WM_INFO_UPDATE, 8, DWORD(PChar(buffer)));
end;

procedure TForm1.cbDirectConnectionClick(Sender: TObject);
begin
  if not TCheckbox(Sender).Checked then
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, @proxy[0]) // enable proxy
  else
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, nil); // disable proxy
end;

procedure TForm1.WndProc(var Msg: TMessage);
// to be threadsave we are passing all Canvas Stuff(e.g. Labels) to this messages
begin
  inherited;
  if Msg.Msg = WM_INFO_UPDATE then
    case msg.WParam of
      0:
        begin
          Label4.Caption := 'Stream wird geladen ';
          Label3.Caption := 'Titel wird geladen';
          Label5.Caption := 'bitrate wird berechnet';
        end;
      1:
        begin
          Label4.Caption := 'not playing';
          //Error('Can''t play the stream');
         MessageBox(win, PChar('Can''t play the stream' + #13#10 + '(error code: ' +
            IntToStr(msg.LParam)+')'), nil, 0);

        end;
      2: Label4.Caption := Format('buffering... %d%%', [msg.LParam]);
      3: Label4.Caption := PChar(msg.LParam);
      4: Label5.Caption := PChar(msg.LParam);
      5: Label5.Caption := PChar(msg.LParam);
      6: Label3.Caption := PChar(msg.LParam);
      7: Label3.Caption := PChar(msg.LParam);
      8: Label5.Caption := PChar(msg.LParam);
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  // check the correct BASS was loaded
  win := handle;
  if (HIWORD(BASS_GetVersion) <> BASSVERSION) then
  begin
    MessageBox(0, 'An incorrect version of BASS.DLL was loaded', nil, MB_ICONERROR);
    Halt;
  end;
  if (not BASS_Init(-1, 44100, 0, Handle, nil)) then
  begin
    Error('Can''t initialize device');
    Halt;
  end;
  BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1); // enable playlist processing
  BASS_SetConfig(BASS_CONFIG_NET_PREBUF, 0); // minimize automatic pre-buffering, so we can do it (and display it) instead
  BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, @proxy[0]); // setup proxy server location
  end;
  begin
  Bassvolume.Volume := 100;
end;

function OpenURL(url: PChar): Integer;
var
  icy: PChar;
  Len, Progress: DWORD;
begin
  Result := 0;
  BASS_StreamFree(chan); // close old stream
  progress := 0;
  SendMessage(win, WM_INFO_UPDATE, 0, 0); // reset the Labels and trying connecting

  chan := BASS_StreamCreateURL(url, 0, BASS_STREAM_STATUS, @StatusProc, 0);
  if (chan = 0) then
  begin
    //lets catch the error here inside the Thread
    // and send it to the WndProc
    SendMessage(win, WM_INFO_UPDATE, 1, Bass_ErrorGetCode()); // Oops Error
  end
  else
  begin
    // Progress
    repeat
      len := BASS_StreamGetFilePosition(chan, BASS_FILEPOS_END);
      if (len = DW_Error) then
        break; // something's gone wrong! (eg. BASS_Free called)
      progress := (BASS_StreamGetFilePosition(chan, BASS_FILEPOS_DOWNLOAD) -
        BASS_StreamGetFilePosition(chan, BASS_FILEPOS_CURRENT)) * 100 div len;
      // percentage of buffer filled
      SendMessage(win, WM_INFO_UPDATE, 2, progress); // show the Progess value in the label

    until
      progress > 75;

    // get the broadcast name and bitrate
    icy := BASS_ChannelGetTags(chan, BASS_TAG_ICY);
    if (icy = nil) then
      icy := BASS_ChannelGetTags(chan, BASS_TAG_HTTP); // no ICY tags, try HTTP
    if (icy <> nil) then
      while (icy^ <> #0) do
      begin
        if (Copy(icy, 1, 9) = 'icy-name:') then
          SendMessage(win, WM_INFO_UPDATE, 3, DWORD(PChar(Copy(icy, 10, MaxInt))))

        else if (Copy(icy, 1, 7) = 'icy-br:') then

          SendMessage(win, WM_INFO_UPDATE, 4, DWORD(PChar('bitrate: ' + Copy(icy, 8, MaxInt))));
        icy := icy + Length(icy) + 1;
      end;
    // get the stream title and set sync for subsequent titles
    DoMeta();
    BASS_ChannelSetSync(chan, BASS_SYNC_META, 0, @MetaSync, 0);
    // play it!
    BASS_ChannelPlay(chan, FALSE);
  end;
  cthread := 0;
end;

procedure DoMeta();
var
  meta: PChar;
  p: Integer;
begin
  meta := BASS_ChannelGetTags(chan, BASS_TAG_META);
  if (meta <> nil) then
  begin
    p := Pos('StreamTitle=', meta);
    if (p = 0) then
      Exit;
    p := p + 13;
    SendMessage(win, WM_INFO_UPDATE, 7, DWORD(PChar(Copy(meta, p, Pos(';', meta) - p - 1))));
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  BASS_Free;
end;


procedure TForm1.sButton1Click(Sender: TObject);
begin
  if not TCheckbox(Sender).Checked then
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, @proxy[0]) // enable proxy
  else
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, nil); // disable proxy
end;

procedure TForm1.sButton2Click(Sender: TObject);
var
  ThreadId: Cardinal;
begin
  StrPCopy(proxy,ed_ProxyServer.Text); // copy the Servertext to the Proxy array
  if (cthread <> 0) then
    MessageBeep(0)
  else
    cthread := BeginThread(nil, 0, @OpenURL, PChar(urls[TButton(Sender).Tag]), 0, ThreadId);
end;


procedure TForm1.sButton3Click(Sender: TObject);
begin
 Form1.Close
end;

procedure TForm1.sButton4Click(Sender: TObject);
begin
 Form2.show
end;


end.


Zuletzt bearbeitet von Naxor am Fr 02.10.09 19:42, insgesamt 1-mal bearbeitet
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 02.10.09 18:59 
Den Typ TBassVolume kenne ich jetzt nicht, aber das muss nichts heißen.

Warum ist bassvolume zweimal definiert?

_________________
We are, we were and will not be.
Naxor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

alle
delphi, C++, php, html, java, flash, XML
BeitragVerfasst: Fr 02.10.09 19:23 
ohhh ist mir garnicht aufgefallen das FormCreate 2 mal drin steht..

ja das bassvolume ist von bass damit gehts aber nicht.. habe es auch bei mir mit deinem quelltext versucht

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.VolumeScrollbarScroll(Sender: TObject;
  ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
  MeMPPlaylist.Volume := (100 - Scrollpos) / 100;
end;


aber dann kommt immer fehler das MeMPPlayerlist.Volume irgendwie nicht stimmt