Thema: Delphi Problem mit Threads

Einzelnen Beitrag anzeigen

Nils_13

Registriert seit: 15. Nov 2004
2.647 Beiträge
 
#7

Re: Problem mit Threads

  Alt 28. Jan 2007, 16:25
Irgendwie scheint heute nicht mein Tag zu sein... Bittesehr:
Delphi-Quellcode:
function OpenURL(url: PChar) : Integer;
var
  icy: PChar;
  Len, Progress: DWORD;
begin
  Result := 0;
  BASS_StreamFree(chan); // Alten Stream beenden
  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, 0); // Fehler
  end else
  begin
    // Progress
    repeat
      len := BASS_StreamGetFilePosition(chan, BASS_FILEPOS_END);
      if (len = DW_Error) then
        Break; // Fehler
      progress := (BASS_StreamGetFilePosition(chan, BASS_FILEPOS_DOWNLOAD) -
        BASS_StreamGetFilePosition(chan, BASS_FILEPOS_CURRENT)) * 100 div len;
      // Buffer Prozent
      SendMessage(win, WM_INFO_UPDATE, 2, progress);

    until
      progress > 75;

    // Name + Bitrate
    icy := BASS_ChannelGetTags(chan, BASS_TAG_ICY);
    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;
    // Stream-Titel + Sync setzen
    DoMeta(BASS_ChannelGetTags(chan, BASS_TAG_META));
    BASS_ChannelSetSync(chan, BASS_SYNC_META, 0, @MetaSync, 0);
    // Abspielen
    BASS_ChannelPlay(chan, FALSE);
  end;
  cthread := 0;
end;
  Mit Zitat antworten Zitat