Jump to content

Play streaming with bass.dll


Recommended Posts

Hi, im working very hard on my radio software. I use windows media plyer, but i want to reproduce the streaming with bass.dll.

How i can do this? How i can reprocuce a streaming file with bass.dll

I've this code but don't worK:

#include <Bass.au3>
#include <BassConstants.au3>

$bass_dll = DllOpen("C:\bass.dll")
If @error Then
    MsgBox(0, "Error", "Could not load bass.dll")
    Exit
EndIf
;Initalize bass.  Required for most functions.
_BASS_Init ($bass_dll, 0, -1, 44100, 0, "")

;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf
$file = "http://bbc.co.uk/radio/listen/live/r1.asx" ;radio streaming link
$MusicHandle = _BASS_StreamCreateURL ($bass_dll, $file, 0, 1)

How i can fix that? Sorry for my english :x

hI!

Link to comment
Share on other sites

I see several problems with how you're using the Bass functions. First, use _Bass_startup("C:\bass.dll") instead of Dllopen. Second, don't use the return from the dllopen in any of the other _Bass_ functions, you need to read how to use those functions, because you're calling them all wrong.

_Bass_Init doesn't need to know anything about the DLLopen return, so change that to _BASS_Init (0, -1, 44100, 0, ""). Then your call for _Bass_StreamCreateURL is formatted wrong, the first parameter is the URL that you are downloading from, not the return from the DllOpen statement.

If I were you, I'd open up the Bass.Au3 file and study the information in there as to how to use the functions correctly, it's pretty obvious that you haven't.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thank's for help, but i dont have understand very well how to use _Bass_StreamCreateURL(). I've this code but don't work :P

#include <Bass.au3>
#include <BassConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
$Form1 = GUICreate("Form1", 117, 83, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 24, 24, 75, 25)
GUISetState(@SW_SHOW)
_Bass_startup("C:\bass.dll")
If @error Then
    MsgBox(0, "Error", "Could not load bass.dll")
    Exit
EndIf
;Initalize bass.  Required for most functions.
_BASS_Init (0, -1, 44100, 0, "")

;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $file = "http://bbc.co.uk/radio/listen/live/r1.asx"
            $MusicHandle = _BASS_StreamCreateURL (False,$file, 0,1)
    EndSwitch
WEnd

How i can fix that?...thanks for your help :x

Link to comment
Share on other sites

Changing this:

$file = "http://bbc.co.uk/radio/listen/live/r1.asx"
            $MusicHandle = _BASS_StreamCreateURL (False,$file, 0,1)

To this:

$file = "http://bbc.co.uk/radio/listen/live/r1.asx"
$MusicHandle = _BASS_StreamCreateURL($file, 0, 1)

When I run it through SciTE with debugging on the $MusicHandle variable I get back the information below, which tells me that the file format is wrong for the _Bass_StreamCreateURL function. So, that tells me that Bass either won't play that stream, or the $flag parameter is wrong. I don't know enough about the bass library to comment on how that should be set up, or even if the .asx will play with Bass.

@@ Debug(9) : $MusicHandle = 0 
>Error code: 41

From the BassConstants.au3 file
Global Const $BASS_ERROR_FILEFORM = 41  ;unsupported file format
Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Instead of bumping this thread, you might want to include what it is that you need before bumping it again. As it stands right now, the code you're writing is written wrong, I have told you how to fix it. The stream you're trying to connect to can't be played by the Bass UDF, so what exactly are you bumping the thread for? You need to tell us what help is being asked for, otherwise you're just being annoying in bumping this thread.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

For reproduce .asx file i need to load basswma.dll, i try with _BASS_PluginLoad function but nothing work:

I've this code:

#include <Bass.au3>
#include <BassConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
$Form1 = GUICreate("Form1", 117, 83, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 24, 24, 75, 25)
GUISetState(@SW_SHOW)
_Bass_startup("C:\bass.dll")
_BASS_PluginLoad("C:\basswma.dll",0)
_BASS_SetConfig($BASS_CONFIG_WMA_ASX, 1)
If @error Then
    MsgBox(0, "Error", "Could not load bass.dll")
    Exit
EndIf
;Initalize bass.  Required for most functions.
_BASS_Init (0, -1, 44100, 0, "")

;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $file = "http://bbc.co.uk/radio/listen/live/r1.asx"
            $MusicHandle = _BASS_StreamCreateURL($file, 0, 1)
    EndSwitch
WEnd

Basswma.dll can be downloaded here...can u help me to fix this code :P

Thank's :x

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...