|
Hi
I am new to VB.net wanted to know how to play wave audio files one after another? I tried a code by giving file names one after another. Here the last file plays. The first file is not playing. I think its too fast! How to control it. I have a class called soundplayer. The code is as follows
Imports System
Imports DxVBLib
Public Class SoundPlayer
' Basic Wave and MIDI Player Class for VB.net 1.1
' Requires COM-Object : DirectX7
Private Declare Function mciSendString Lib "Winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private File As String
Private m_dx As New DirectX7()
Private m_ds As DirectSound
Public Sub New(ByVal strFileName As String)
Me.File = strFileName
End Sub
' To show what file is selected (if needed)
Public ReadOnly Property FileName() As String
Get
Return File
End Get
End Property
Public Function PlaySound() As Boolean
If InitAudio() = True Then
If PlayFile() = True Then
Return True
Else
Return False
End If
Else
' Audiohardware not found
' exit here
Return False
End If
End Function
Public Function StopSound() As Boolean
StopFile()
End Function
Private Function PlayFile() As Boolean
Dim lRet As Long
Try
StopFile()
lRet = mciSendString("open " & Me.File & " alias track", "", 0, 0)
lRet = mciSendString("play track", "", 0, 0)
PlayFile = (lRet = 0)
Catch ex As Exception
Return False
End Try
Return True
End Function
Public Function CloseAudio()
mciSendString("close all", 0, 0, 0)
End Function
Private Function StopFile() As Boolean
Dim lRet As Long
Try
lRet = mciSendString("stop track", "", 0, 0)
lRet = mciSendString("close track", "", 0, 0)
Return True
Catch ex As Exception
Return False
End Try
End Function
Private Function InitAudio() As Boolean
m_ds = m_dx.DirectSoundCreate("")
If Err.Number <> 0 Then
Return False
Else
Return True
End If
End Function
End Class
in the form I have written the following code
Public Class frmIVA
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'frmIVA
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "frmIVA"
Me.Text = "Interactive"
End Sub
#End Region
Private Sub frmIVA_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fileName As String
fileName = "welcome.wav"
Play(fileName)
fileName = "zodmon.wav"
Play(fileName)
fileName = "press12.wav"
Play(fileName) End Sub
Public Sub Play(ByVal file)
Dim pathName As String = "E:\iva\audio\"
Dim Sound As New SoundPlayer(pathName & file)
Sound.PlaySound()
End Sub
End Class
Please Help
Thanks in Advance
|
|
|
|
|
meghanaVishwa wrote: fileName = "zodmon.wav"
Play(fileName)
fileName = "press12.wav"
Play(fileName)
Obviously, this will change the file right away. I don't know if the code you're using supports an event when playback ends, but the windows media player control and the managed directx classes for playing audio, both do, and the WMP control lets you build a playlist, also.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Guys,
Does anyone of you know where can I download Sheridan Ultragrid 1.0 installer for visual basic 6?
Thanks in advance
hifiger2004
|
|
|
|
|
Normally I'd assume you were trying to steal this component, but in this case, I assume that it's not longer available because VB6 is a dead language, and has been for many years. Why are you still using it ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have my old VB6 source code that uses sheridan which is very important because there's I have a small client who's currently using my program. He called me up and informed me that his pc was just reformatted and need to reinstall the entire program from the CD I gave him 4 years ago. And my problem now is that I don't have my sheridan installer anymore.
That's why I am trying to search for a sheridan installer inorder for me to reinstall back my program into his computer.
I acquired the Sheridan installer from a friend before, but when I contacted him now his mobile# is unreachable.
So meaning, there's no other site now that distributes trial version?
Because if there's only a trial version, I can easily get into my source code and for me to have a chance to change it to other native components in VB6. The important thing for me now is to trace back the functionalities thru the use of sheridan component before moving to the next step.
Thanks
hifiger2004
|
|
|
|
|
I don't know, you'd have to google for it. It would not surprise me, but then, why not keep selling it, it costs nothing to keep it on the inventory.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi.
this is my first post here on code project, but i already read many articles. i believe this is the right place to ask my question.
here is the interface which is implemented in the product class:
Public Interface IGridMarkable
ReadOnly Property sort() As Short
Property valid() As SqlBoolean
ReadOnly Property pflicht() As Boolean
End Interface
Now I have another class with a method setref(byref Dictionary(of short, IGridMarkable)).
When i try to call this method this method like this:
dim list as dictionary(of short, product)
anotherclassobject.setref(list)
the compiler tells me that this can not be converted. ctype(list,dictionary(of short, IGridMarkable)) doesn't work either.
can anyone explain me this behaviour?
--edit
Is it possible to define the conversion from product to IGridMarkable in the product class?
--edit
thanks in advance,
steffen.
modified on Thursday, March 6, 2008 4:13 AM
|
|
|
|
|
I'm surprised, I'd have expected you could do this.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi christian.
i thought that too.
steffen.
|
|
|
|
|
Are you absolutely sure the Product class Implements IGridMarkable??
|
|
|
|
|
hello dave.
see for yourself (i shortened it down to the necessary things)
Public Interface IGridMarkable
ReadOnly Property sort() As Short
Property valid() As SqlBoolean
ReadOnly Property must() As Boolean
End Interface
Public Class product
Implements IGridMarkable
#Region "private member vars"
Private _sort As Long
Private _valid As SqlBoolean = SqlBoolean.Null
Private _must As Boolean
#End Region
#Region "properties"
Public ReadOnly Property sort() As Short Implements IGridMarkable.sort
Get
Return Me._sort
End Get
End Property
Public ReadOnly Property must() As Boolean Implements IGridMarkable.must
Get
Return _must
End Get
End Property
Public Property valid() As SqlBoolean Implements IGridMarkable.valid
Get
Return _valid
End Get
Set(ByVal value As SqlBoolean)
#If DEBUG Then
Debug.WriteLine("Produkt: " + Me.sort.ToString + " valid: " + value.ToString)
#End If
_valid = value
End Set
End Property
#End Region
End Class
Could it be that the problem lies in trying to cast the collection instead of one single product?
steffen.
|
|
|
|
|
OK. I just tried this and it failed. I, too, would have thought this should have worked.
Hmmm.... still playing around with this one.
OK. It looks like you're going to have to create the list Dictionary using IGridMarkable , not Product :
Dim list As New Dictionary(Of Short, IGridMarkable)
list.Add(some short, New Product())
someClass.setRef(list)
The type cast won't work because the Dictionary is, internally, a collection of KeyValuePair(Of type, type) objects, which the type cast won't transfer to.
|
|
|
|
|
i'll try this when i'm back at work. my problem is that i work with this dictionary application wide, where the IGridMarkable-propertys of the product are changed. But I need the "normal" product propertys too. Maybe I could just make another Dictionary(of short, IGridMarkable) where i add references to the real products, but this is a waste of memory.
well, thank you, i'll go home now.
|
|
|
|
|
hello all.
i won't be at work the next 2 weeks, so don't be suprised if i don't answer.
thank you for your efforts.
steffen.
|
|
|
|
|
Working in VB.Net, Visual Studio 2000 Standard, Windows XP Pro.
Using a 3rd party video editor ActiveX control.
Have 3 forms in the program using this control. First time one of the forms is opened, the ActiveX control performs correctly. After the form is closed, attempting to open any of the 3 forms with this control throws an exception error:
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in system.windows.forms.dll
Additional information: Unable to get the window handle for the 'AxVideoEdit' control. Windowless ActiveX controls are not supported.
The line in the program VisualStudio stops at is located in the "Windows Form Designer generated code" section for the details on the form being opened:
CType(Me.vidEdit, System.ComponentModel.ISupportInitialize).EndInit()
(vidEdit is the VideoEdit ActiveX control)
Following is the error message details when running the actual program:
************************************************
************************************************
************************************************
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Reflection.TargetInvocationException: Unable to get the window handle for the 'AxVideoEdit' control. Windowless ActiveX controls are not supported. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.IOleObject.DoVerb(Int32 iVerb, IntPtr lpmsg, IOleClientSite pActiveSite, Int32 lindex, IntPtr hwndParent, COMRECT lprcPosRect)
at System.Windows.Forms.AxHost.DoVerb(Int32 verb)
at System.Windows.Forms.AxHost.InPlaceActivate()
--- End of inner exception stack trace ---
at System.Windows.Forms.AxHost.InPlaceActivate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.AxHost.EndInit()
at MyProgram.VidEdit.InitializeComponent()
at MyProgram.VidEdit..ctor()
at MyProgram.StartProgram.lblClipEdit_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/microsoft.net/framework/v1.0.3705/mscorlib.dll
----------------------------------------
ActionPlusVideo
Assembly Version: 1.0.2980.30757
Win32 Version: 1.0.2980.30757
CodeBase: file:///C:/Program%20Files/MyProgram/MyProgram.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.3300.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/assembly/gac/system/1.0.3300.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.0
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
AxInterop.VIDEOEDITLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/MyProgram/AxInterop.VIDEOEDITLib.DLL
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 7.0.3300.0
Win32 Version: 7.00.9466
CodeBase: file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.3300.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
----------------------------------------
Interop.VIDEOEDITLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/MyProgram/Interop.VIDEOEDITLib.DLL
----------------------------------------
AxInterop.MOVIEPLAYERLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/MyProgram/AxInterop.MOVIEPLAYERLib.DLL
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
************************************************
************************************************
************************************************
Have tried using the forms with and without vidEdit.Dispose(), MyBase.Dispose(), etc., but no success.
Any suggestions?
|
|
|
|
|
Sounds like it's not supported. What control do you use ? I use the Datastead TVideoGrabber, and it's worked out really well, and their support is excellent.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Using Viscom's VideoEdit ActiveX.
The error report shows there is no instance of the ActiveX control to access, but it works fine the first time through. The com wrapper is being lost somehow when closing the form and not being reproduced when another instance of the ActiveX control is called for. Any answers on why this could be happenning and how to prevent it?
|
|
|
|
|
No, but I'd say the authors of your component are the best folks to ask.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I want to exit a for each loop early. How do I do that.
Here is my loop? Some code from inside the loop is missing.
For Each row As DataRow In dtGetLid.Rows
dtCkLessStat.Clear()
Call checkLessonStatus(Convert.ToInt32(row("less_id")), dtpText)
Next
Can I put it in a function and then exit the function when the loop finds a particular condition?
How do I exit the function?
|
|
|
|
|
In C#, you put the break keyword to exist a loop. Not sure if it works for foreach, or if the syntax is the same in VB. I wouldn't use foreach unless I intended to iterate over them all. I'd use a for loop for that, or better yet, a while loop that can be set up to break naturally, without a break statement inside the loop.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
The break keyword does not work in VB.NET. Would it work to clear the dataTable?
|
|
|
|
|
Then there is probably another word in VB. However, a while loop is the nicest solution.
Would what work ? The break keyword won't cleay anything, and any sort of loop is going to run the code inside the loop.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am not sure, but if I understand your problem you just need something to exit FOR loop.
You can use Exit For for this.
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
hi
how i can display the relation betwwen tables in the datagridview control;
|
|
|
|
|
I have a VB.NET VS2008 windows form application where I have a crystalviewer form setup to print a few reports out from the menu off of the main data entry form.
The crystal reports are already written and stored in a folder on one of our servers (For this example lets call it \\MyServer\ReportFolder\). The crystal report uses a DSN to know where to find the data (For this example lets call it MyCrystalDSN).
The code on the menu fires off the report as shown below:
Dim frmCV As New frmCrystalViewer
frmCV.CrystalReportViewer1.ReportSource = "\\MyServer\ReportFolder\Reportname.rpt"
frmCV.WindowState = FormWindowState.Maximized
frmCV.ShowDialog()
Ok, everything works great for now, but of course it never fails that when you develop at your desk with all the rights available as a developer it all works and when you deploy the app, everything never works as planned.
When I publish the project for use by the client, I have to setup a DSN so the Crystal Reports will work.
Can I do this on the fly with code? For example, my crystal reports are using the MyCrystalDSN, and I don't want to have to remember to setup a DSN for everyone's computer I deploy the application on. Can I code the DSN information to use in the code prior to firing off the report?
A coworker gave me the following code from an article that I believe was written in 2001 for VB6. Is anyone doing this in .NET? Here is that code:
Public Sub RegisterDatabaseSample()
'Create a DSN called TEST on a server called ThatServer
DBEngine.RegisterDatabase "TEST", "SQL Server", True, _
"Database=pubs" & _
vbCr & "Description=Sample DSN" & _
vbCr & "Server=ThatServer"
End Sub
Any help is appreciated
Lost in the vast sea of .NET
|
|
|
|
|