Author Topic: How can I check the netradio music kind  (Read 542 times)

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: How can I check the netradio music kind
« Reply #25 on: 9 Feb '21 - 16:14 »
What is the "info.ctype" value?

Chris

  • Posts: 1915
Re: How can I check the netradio music kind
« Reply #26 on: 9 Feb '21 - 17:24 »
Hi you can try this. Tested with Delphi 10.4. Will return "Advanced Audio Coding"

Code: [Select]
function GetCTypeString(ctype: DWORD; plugin: HPLUGIN): string;
var
  pInfo: ^BASS_PLUGININFO;
  a: integer;
  wf: ^TWaveFormatEX;
begin
  if plugin <> 0 then
  begin
    pInfo := Pointer(BASS_PluginGetInfo(plugin));
    for a := 0 to pInfo.formatc - 1 do
      if pInfo.Formats[a].ctype = ctype then
        Result := string(pInfo.Formats[a].name);
  end;
  // check built-in stream formats...
  case ctype of
    BASS_CTYPE_STREAM_OGG:
      Result := Result + '"Ogg Vorbis"';
    BASS_CTYPE_STREAM_MP1:
      Result := Result + '"MPEG layer 1"';
    BASS_CTYPE_STREAM_MP2:
      Result := Result + '"MPEG layer 2"';
    BASS_CTYPE_STREAM_MP3:
      Result := Result + '"MPEG layer 3"';
    BASS_CTYPE_STREAM_AIFF:
      Result := Result + '"Audio IFF"';
    BASS_CTYPE_STREAM_WAV_PCM:
      Result := Result + '"PCM WAVE"';
    BASS_CTYPE_STREAM_WAV_FLOAT:
      Result := Result + '"Floating-point WAVE"';
    BASS_CTYPE_STREAM_WAV:
      Result := Result + '"Wave"';
    BASS_CTYPE_STREAM_AAC:
      Result := Result + 'AAC';
    BASS_CTYPE_STREAM_MF:
      begin
        wf := Pointer(PAnsiChar(BASS_ChannelGetTags(chan,
          BASS_TAG_WAVEFORMAT)));
        if (wf.wFormatTag = $1610) then
          Result := Result + 'Advanced Audio Coding'
        else if (wf.wFormatTag >= $0160) and (wf.wFormatTag <= $0163) then
          Result := Result + 'Windows Media Audio';
      end;
  end;
end;
« Last Edit: 9 Feb '21 - 17:52 by Chris »

Chris

  • Posts: 1915
Re: How can I check the netradio music kind
« Reply #27 on: 9 Feb '21 - 17:51 »
-

terry_zhou82

  • Posts: 80
Re: How can I check the netradio music kind
« Reply #28 on: 10 Feb '21 - 07:09 »
Tks chris.
If this code is right?
button1click;
    url:='https://stream.rcs.revma.com/55tyxsy4qtzuv';  //it's the aac audio
    Bass_StreamFree(Chan);
     BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK  or BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE,@StatusProc, nil);
    if CHan <> 0 then
    begin
      BASS_ChannelGetInfo(chan, info);
      ShowMessage(getCTypeString(info.ctype, info.plugin));
    end;  //there's show AAC ?

terry_zhou82

  • Posts: 80
Re: How can I check the netradio music kind
« Reply #29 on: 10 Feb '21 - 12:38 »
Dear Chris:
I use the code as you provide of gettype,but if I want to get the type of radiostation,it's only wrong.
(I use Delphi XE8)

procedure TForm1.Button1Click(Sender: TObject);
var
  Info: Bass_ChannelInfo;
  URL:string;
begin
    url:='https://stream.rcs.revma.com/55tyxsy4qtzuv';
    Bass_StreamFree(Chan);
     BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK  or BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE,@StatusProc, nil);
    if CHan <> 0 then
    begin
      BASS_ChannelGetInfo(chan, info);
      ShowMessage(getCTypeString(info.ctype, info.plugin));
    end;  //showmessage doesn't work and show nothing,what's wrong about this code?
« Last Edit: 10 Feb '21 - 13:05 by terry_zhou82 »

Ed1966

  • Posts: 169
Re: How can I check the netradio music kind
« Reply #30 on: 10 Feb '21 - 13:37 »
Hi,

You are using: (First code example you did this right)

Code: [Select]
Bass_StreamFree(Chan);
BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK  or BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE,@StatusProc, nil);

Must be:

Code: [Select]
Bass_StreamFree(Chan);
Chan := BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK  or BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE,@StatusProc, nil);

Return value: BASS_StreamCreateURL
If successful, the new stream's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.

Good luck.
Eduard.

terry_zhou82

  • Posts: 80
Re: How can I check the netradio music kind
« Reply #31 on: 10 Feb '21 - 14:18 »
Dear Ed1966
It's doesn't work either.
.......
  Bass_StreamFree(Chan);
     url:='https://stream.rcs.revma.com/55tyxsy4qtzuv';
    CHAN:= BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK  or BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE,@StatusProc, nil);
    Button1.Caption:=IntToStr(BASS_ErrorGetCode); //caption is 20, it mens The length must be specified when streaming from memory.

So I don't know what to do the next...

Ed1966

  • Posts: 169
Re: How can I check the netradio music kind
« Reply #32 on: 10 Feb '21 - 15:37 »
Add flag:

 or BASS_UNICODE
« Last Edit: 10 Feb '21 - 15:47 by Ed1966 »

terry_zhou82

  • Posts: 80
Re: How can I check the netradio music kind
« Reply #33 on: 13 Feb '21 - 03:50 »
Tks, I'll check it.