0
0

Public Delegate Function STREAMCALLBACK(ByVal stream As IntPtr, _
ByVal buff As IntPtr, _
ByVal length As Integer, _
ByVal userdata As IntPtr) As Byte

<DllImport(“fmodce.dll”)> _
Shared Function FSOUND_Stream_SetEndCallback(ByVal FSOUND_STREAM_stream As IntPtr, _
ByVal FSOUND_STREAMCALLBACK_callback As STREAMCALLBACK, _
ByVal userdata As IntPtr) As Boolean
End Function

Private m_ptr As New IntPtr(0)
Public Function EndSongCallback(ByVal stream As IntPtr, _
ByVal buff As IntPtr, _
ByVal length As Integer, _
ByVal userdata As IntPtr) As Byte
m_bPlaying = False
FSOUND_Stream_Close(m_ptr)
End Function

Sub Play(ByVal m_msPlay As System.IO.MemoryStream)
m_bPlaying = True

Dim hfile As GCHandle
Dim pfilename As IntPtr

hfile = GCHandle.Alloc(m_PlayBuffer, GCHandleType.Pinned)
pfilename = New IntPtr(hfile.AddrOfPinnedObject().ToInt32 + 4)
m_pfilename = pfilename

m_ptr = FSOUND_Stream_Open(pfilename, FSOUND_MODES.FSOUND_LOADMEMORY, 0, m_PlayBuffer.Length)

😳
FSOUND_Stream_SetEndCallback(m_ptr, New STREAMCALLBACK(AddressOf EndSongCallback), New IntPtr(0))

FSOUND_Stream_Play(-1, m_ptr)

If hfile.IsAllocated Then hfile.Free()

End Sub

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.