This project is read-only.
1) NV2 Usage example for VB .NET

'This example shows you how to play and stop *.v2m files.
'In this example, I have named my music file "Flowers.v2m".
'If you search for these music files you can get them e.g. here: .
'IMPORTANT: Set the compiler output to x86 (Project->Properties->Compile->x86),
'otherwise NV2 won´t work.

'Code usage:

'Start a new Winforms VB .NET 2008 Project.
'Set a reference to the NV2.dll : "Project" -> "Add reference" -> browse for NV2.dll .
'Now setup the Import once to avoid too long declarations:

Imports NV2.NV2

'Note: Put the next 2 lines on top of your code.

'Declare a new class object with events:

Public WithEvents NV2 As New NV2.NV2

'Declare a GAC handle object to pinn the music file in memory later:

Public hGcObj As GCHandle

'Now I show you 2 options to read a *.v2m music file:
'From a path or the Programs Ressources.
'Choose the suitable option for your usage!

'1) Read the *.v2m file from a path (to a Bytearray):

Dim Song() As Byte = My.Computer.FileSystem.ReadAllBytes("C:\Users\Freefall\Desktop\Flowers.v2m")

'2) Read the *.v2m file out of the Programs Ressources (to a Bytearray):
'Of course you need to put it into the ressources before!
'To do this, goto "Project" -> "Properties" -> "Ressources" -> drag & drop the file in.

Dim Song() As Byte = My.Resources.Flowers

'-> Finally use the NV2 function to play the song,
'and ensure to pinn the song bytearray in memory to avoid GAC issues.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
hGcObj = GCHandle.Alloc(Song, GCHandleType.Pinned)
End Sub

'Stop & unload the song and free the song bytearray for the GAC.

Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
End Sub

'Note, that you can include any .NET .dll after compiling with Ilmerge from Microsoft!!!

Last edited Oct 21, 2013 at 3:10 PM by Freefall, version 19


No comments yet.