I would like to create a basic little .net wrapper to easily stream internet radio's. It needs to be .Net 2.0.The initalize works, However when i start BASS_ChannelPlay i basicly hear some sound, but VERY jerky and crackling. What goes wrong?
My code:
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime;
using System.Runtime.InteropServices;
public class bass : MonoBehaviour {
public enum flags {
BASS_DEFAULT
}
public enum configs {
BASS_CONFIG_NET_PLAYLIST
}
[DllImport("bass.dll")]
public static extern bool BASS_Init(int device, int freq, int flag,IntPtr hwnd, IntPtr clsid);
[DllImport("bass.dll")]
public static extern bool BASS_SetConfig(configs config,int valuer);
[DllImport("bass.dll")]
public static extern Int32 BASS_StreamCreateURL(string url,int offset,flags flag);
[DllImport("bass.dll")]
public static extern bool BASS_ChannelPlay(int steam,bool restart);
[DllImport("bass.dll")]
public static extern bool BASS_StreamFree(int stream);
[DllImport("bass.dll")]
public static extern bool BASS_Free();
private int stream;
void Start () {
if ( BASS_Init(-1, 44100,0,IntPtr.Zero, IntPtr.Zero) ) { //works
BASS_SetConfig(configs.BASS_CONFIG_NET_PLAYLIST,2);
stream = BASS_StreamCreateURL("http://91.121.149.200:8100/",0,flags.BASS_DEFAULT);
if (stream != 0) { //works
BASS_ChannelPlay(stream, false);
}
}
}
void OnApplicationQuit() {
BASS_StreamFree(stream);
BASS_Free();
}