Author Topic: How can I play the mms:// ??  (Read 719 times)

terry_zhou82

  • Posts: 21
How can I play the mms:// ??
« on: 24 Jul '17 - 15:04 »
Hi,guys
I want to use the code to play the mms://
first,I loadthe code as follow;
I use the basswma.pas and basswma.dll

procedure TForm1.FormCreate(Sender: TObject);
begin
  BASS_PluginLoad('basswma.dll', 0);
  ......
and use the code of button
BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1); // enable playlist processing
  chan := BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK or BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE, @StatusProc, nil);
  ......
but When I play the mms:// it often show BassErrorCode:2
what can i do ?hurry

Ian @ un4seen

  • Administrator
  • Posts: 20724
Re: How can I play the mms:// ??
« Reply #1 on: 24 Jul '17 - 17:36 »
Please give an example URL that you are having trouble with. Also confirm that you are able to play the same URL in other software.

terry_zhou82

  • Posts: 21
Re: How can I play the mms:// ??
« Reply #2 on: 25 Jul '17 - 07:22 »
the website is : mms://simul.freebit.net/fmwing
in the windows media player,it does work;

Ian @ un4seen

  • Administrator
  • Posts: 20724
Re: How can I play the mms:// ??
« Reply #3 on: 25 Jul '17 - 14:56 »
That URL is working fine with BASSWMA here, so that's strange. Please try playing it with the pre-compiled NETRADIO.EXE example included in the BASSWMA package (C\BIN folder). If the URL isn't working with that, also try playing it with XMPlay.

terry_zhou82

  • Posts: 21
Re: How can I play the mms:// ??
« Reply #4 on: 25 Jul '17 - 16:53 »
I didn't find the BASSWMA package (C\BIN folder). ?
where is it?

Ian @ un4seen

  • Administrator
  • Posts: 20724
Re: How can I play the mms:// ??
« Reply #5 on: 25 Jul '17 - 17:18 »
The BASSWMA ZIP package includes a C\BIN folder, and a pre-compiled NETRADIO.EXE file is in there.

What Delphi version are you using? I just noticed that you're not using the BASS_UNICODE flag in your BASS_PluginLoad call. What is the return value? If it's 0, try adding the BASS_UNICODE flag.

terry_zhou82

  • Posts: 21
Re: How can I play the mms:// ??
« Reply #6 on: 25 Jul '17 - 17:46 »
I USE THE DELPHI XE

Chris

  • Posts: 1824
Re: How can I play the mms:// ??
« Reply #7 on: 25 Jul '17 - 22:29 »
Hiu
Quote
chan := BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK or BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE, @StatusProc, nil);
must be
Code: [Select]
chan := BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK or BASS_STREAM_STATUS or  BASS_UNICODE or BASS_STREAM_AUTOFREE, @StatusProc, nil);

terry_zhou82

  • Posts: 21
Re: How can I play the mms:// ??
« Reply #8 on: 26 Jul '17 - 15:07 »
It doesn't work either.
I copy the basswma.dll in the programme Directory
and in the formcreate
begin
BASS_PluginLoad('basswma.dll', 0);
end

and other code change is
chan := BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK or BASS_STREAM_STATUS or BASS_UNICODE or BASS_STREAM_AUTOFREE, @StatusProc, nil);
  .....
but it doesn't work. What can i do ?




Hiu
Quote
chan := BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK or BASS_STREAM_STATUS or BASS_STREAM_AUTOFREE, @StatusProc, nil);
must be
Code: [Select]
chan := BASS_StreamCreateURL(PWideChar(url), 0, BASS_STREAM_BLOCK or BASS_STREAM_STATUS or  BASS_UNICODE or BASS_STREAM_AUTOFREE, @StatusProc, nil);

Ian @ un4seen

  • Administrator
  • Posts: 20724
Re: How can I play the mms:// ??
« Reply #9 on: 26 Jul '17 - 17:02 »
Have you checked the BASS_PluginLoad return value? If not, please do so.

Chris

  • Posts: 1824
Re: How can I play the mms:// ??
« Reply #10 on: 27 Jul '17 - 21:04 »
Hi
Here is a Test with some Errorchecking the url will playing fine (Testplattform win7 x64 , Delphi 10.2)

Code: [Select]
procedure TForm17.FormCreate(Sender: TObject);
// Errorbox TRichedit
begin
  if BASS_Init(-1, 44100, 0, Handle, nil) then
  begin
    ErrorBox.Lines.Add('Bass Load OK');
    //
    if BASS_PluginLoad('basswma.dll', BASS_UNICODE) <> 0 then
      ErrorBox.Lines.Add('BassWMA Load OK')
    else
      ErrorBox.Lines.Add('BassWMA Load Error' + inttostr(BASS_ErrorGetCode()));
     
  // Set Playlist Mode
  if BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1) then // enable playlist processing
    ErrorBox.Lines.Add('Bass Playlist Config OK ')
  else
    ErrorBox.Lines.Add('Bass Playlist Config Error ' + inttostr(BASS_ErrorGetCode()));
  // Set a little bit higher Connection Time OUT
  BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT, 10000);

  url := BASS_StreamCreateURL(PWideChar('mms://simul.freebit.net/fmwing'), 0, BASS_UNICODE, nil, nil);
  if url <> 0 then
  begin
    ErrorBox.Lines.Add('Url Load OK ');
    BASS_ChannelPlay(url, false);
  end
  else
  begin
    ErrorBox.Lines.Add('Error to Load The URL Stream ' + inttostr(BASS_ErrorGetCode()));
     if BASS_ErrorGetCode() = BASS_ERROR_WMA then
        ErrorBox.Lines.Add('Error , BassWMA Codec is not installed');
    end;
  end;
end;
« Last Edit: 28 Jul '17 - 22:05 by Chris »

terry_zhou82

  • Posts: 21
Re: How can I play the mms:// ??
« Reply #11 on: 3 Aug '17 - 16:23 »
Thank you Chris,this code is working.But if I put the another address in it.It doesn't work again. the website just like this:
https://lhttp.qingting.fm/live/386/64k.mp3
codeError is 2 or 20. What can I do ?


Hi
Here is a Test with some Errorchecking the url will playing fine (Testplattform win7 x64 , Delphi 10.2)

Code: [Select]
procedure TForm17.FormCreate(Sender: TObject);
// Errorbox TRichedit
begin
  if BASS_Init(-1, 44100, 0, Handle, nil) then
  begin
    ErrorBox.Lines.Add('Bass Load OK');
    //
    if BASS_PluginLoad('basswma.dll', BASS_UNICODE) <> 0 then
      ErrorBox.Lines.Add('BassWMA Load OK')
    else
      ErrorBox.Lines.Add('BassWMA Load Error' + inttostr(BASS_ErrorGetCode()));
     
  // Set Playlist Mode
  if BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1) then // enable playlist processing
    ErrorBox.Lines.Add('Bass Playlist Config OK ')
  else
    ErrorBox.Lines.Add('Bass Playlist Config Error ' + inttostr(BASS_ErrorGetCode()));
  // Set a little bit higher Connection Time OUT
  BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT, 10000);

  url := BASS_StreamCreateURL(PWideChar('mms://simul.freebit.net/fmwing'), 0, BASS_UNICODE, nil, nil);
  if url <> 0 then
  begin
    ErrorBox.Lines.Add('Url Load OK ');
    BASS_ChannelPlay(url, false);
  end
  else
  begin
    ErrorBox.Lines.Add('Error to Load The URL Stream ' + inttostr(BASS_ErrorGetCode()));
     if BASS_ErrorGetCode() = BASS_ERROR_WMA then
        ErrorBox.Lines.Add('Error , BassWMA Codec is not installed');
    end;
  end;
end;

Ian @ un4seen

  • Administrator
  • Posts: 20724
Re: How can I play the mms:// ??
« Reply #12 on: 3 Aug '17 - 16:54 »
Thank you Chris,this code is working.But if I put the another address in it.It doesn't work again. the website just like this:
https://lhttp.qingting.fm/live/386/64k.mp3
codeError is 2 or 20. What can I do ?

That URL is playing fine here with the pre-compiled NETRADIO.EXE example included in the BASS package (C\BIN folder). Please see if you can reproduce the problem with it there.

Chris

  • Posts: 1824
Re: How can I play the mms:// ??
« Reply #13 on: 3 Aug '17 - 22:18 »
Hi that will have to do with the buffering stuff.
here is a little modified stuff from the orginal netradio example
Code: [Select]
var
  Form1: TForm1;
  url: HSTREAM;
  progress: int64;
  isWMA: boolean = false;
  cthread: DWORD = 0;
  win: hwnd;

function OpenUrl(ur: PWideChar): Integer;
begin
  Result := 0;
  SendMessage(win, WM_INFO_UPDATE, 0, 0);
  url := BASS_StreamCreateURL(PWideChar('https://lhttp.qingting.fm/live/386/64k.mp3'), 0,
    BASS_UNICODE or BASS_SAMPLE_FLOAT or BASS_STREAM_STATUS or BASS_STREAM_BLOCK, nil, nil);
  if url <> 0 then
  begin
    isWMA := BASS_ChannelGetTags(url, BASS_TAG_WMA) <> nil;
    begin
      repeat
        if isWMA then
          progress := BASS_StreamGetFilePosition(url, BASS_FILEPOS_WMA_BUFFER)
        else
          progress := BASS_StreamGetFilePosition(url, BASS_FILEPOS_BUFFER) * 100 div BASS_StreamGetFilePosition(url,
            BASS_FILEPOS_END);
        if (progress = DW_Error) then
          break; // something's gone wrong! (eg. BASS_Free called)
        // percentage of buffer filled
        SendMessage(win, WM_INFO_UPDATE, 2, progress);
      until (progress > 75) or (BASS_StreamGetFilePosition(url, BASS_FILEPOS_CONNECTED) = 0);
      // over 75% full (or end of download)

      SendMessage(win, WM_INFO_UPDATE, 0, 0);
      BASS_ChannelPlay(url, false);
    end
  end
  else
    SendMessage(win, WM_INFO_UPDATE, 0, 0);
  cthread := 0;
end;

LHSoft

  • Posts: 2
Re: How can I play the mms:// ??
« Reply #14 on: 30 Mar '18 - 11:07 »
Hello,
I have the same Problems, but can more specify.

First of all: the Problem occurs only with 64bit Version of bass.dll: compiling in Delphi 10.2.3 in 64bit mode using the actual 64bit version of bass.dll.
If starting the program in 64bit and connecting to stream everything is ok, but if stopping and starting again brings error 20, or if basswma (64bit) is loaded, error 2.
This error occurs not with all streams, but they are always the same where the error occurs (think streams without wma).

Using all in 32bit, there are no problems at all.

Maybe that helps finding the error.

best regards
Hans

LHSoft

  • Posts: 2
Re: How can I play the mms:// ??
« Reply #15 on: 31 Mar '18 - 01:38 »
Hi at all and @unseen developers,

Problem SOLVED!
It is the Thread !
in my uptodate Delphi 10.2.3 the kind, you start the thread in your netradio demo:
Code: [Select]
cthread := BeginThread(nil, 0, @OpenURL, PWideChar(AnsiString(Url)), 0, ThreadId);causes Delphi sometimes to misformat the transmitted string. This happens in 64bit mode mostly, in 32bit mode only a few times, preferred at first time.

So my suggestion is to call OpenURL without thread:
Code: [Select]
OpenURL(PWideChar(AnsiString(Url)));or in a fully constructed thread (did not yet try, and this moment I see no need).

Best Regards,
Hans
« Last Edit: 31 Mar '18 - 01:41 by LHSoft »