Table of callback functions used with BASS_StreamCreateFileUser(BASSStreamSystem, BASSFlag, BASS_FILEPROCS, IntPtr).
Inheritance Hierarchy
Un4seen.BassBASS_FILEPROCS
Namespace: Un4seen.Bass
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax
[SerializableAttribute] [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class BASS_FILEPROCS
The BASS_FILEPROCS type exposes the following members.
Constructors
Name | Description | |
---|---|---|
BASS_FILEPROCS |
Default constructor taking the callback delegates.
|
Fields
Name | Description | |
---|---|---|
close |
Callback function to close the file.
| |
length |
Callback function to get the file length.
| |
read |
Callback function to read from the file.
| |
seek |
Callback function to seek in the file. Not used by buffered file streams.
|
Remarks
Examples
using Un4seen.Bass; ... private BASS_FILEPROCS _myStreamCreateUser; private FileStream _fs; ... Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle); // creating the user file callback delegates _myStreamCreateUser = new BASS_FILEPROCS( new FILECLOSEPROC(MyFileProcUserClose), new FILELENPROC(MyFileProcUserLength), new FILEREADPROC(MyFileProcUserRead), new FILESEEKPROC(MyFileProcUserSeek)); // open the file... _fs = File.OpenRead("test.mp3"); // create the stream (the PRESCAN flag shows you what BASS is doing at the beginning to scan the entire file) // if that generates to much output for you, you can simply remove it int stream = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_NOBUFFER, BASSFlag.BASS_STREAM_PRESCAN | BASSFlag.BASS_STREAM_AUTOFREE, _myStreamCreateUser, IntPtr.Zero); // play the channel Bass.BASS_ChannelPlay(stream, false); ... private void MyFileProcUserClose(IntPtr user) { if (_fs == null) return; _fs.Close(); Console.WriteLine("File Closed"); } private long MyFileProcUserLength(IntPtr user) { if (_fs == null) return 0L; return _fs.Length; } private int MyFileProcUserRead(IntPtr buffer, int length, IntPtr user) { if (_fs == null) return 0; try { // at first we need to create a byte[] with the size of the requested length byte[] data = new byte[length]; // read the file into data int bytesread = _fs.Read(data, 0, length); // and now we need to copy the data to the buffer // we write as many bytes as we read via the file operation Marshal.Copy(data, 0, buffer, bytesread); return bytesread; } catch { return 0; } } private bool MyFileProcUserSeek(long offset, IntPtr user) { if (_fs == null) return false; try { long pos = _fs.Seek(offset, SeekOrigin.Begin); return true; } catch { return false; } }
See Also