473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

MciSendString

Could anyone tell me what am i doing bad?

When i use the "MciSendString" always returns a big number instead 0 : What
it says that there is an error, and so don't play the sound.

Then direction of the sound .wav it's ok

I must not use any .ocx.

Could anyone compile it and tell me what it's wrong?

This is the code:

Public Class Form1
Inherits System.Windows.Forms.Form

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
Declare Function mciGetErrorString Lib "winmm.dll" Alias
"mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String,
ByVal uLength As Long) As Long

Private Direccion As String
Private cadena As String

Sub MandarMensaje(ByVal mensaje As String)
Dim resultado As Long

cadena = Space(255)
resultado = mciSendString(mensaje, cadena, Len(cadena), 0)
BuscarError(resultado)
End Sub
Sub BuscarError(ByVal número As Long)
Dim errorBE As String

errorBE = Space(255)
mciGetErrorString(número, errorBE, 255)
Label1.Text = errorBE
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog
openFileDialog1.InitialDirectory = CurDir() & "\Sonidos"
openFileDialog1.FilterIndex = 1
openFileDialog1.RestoreDirectory = True

If openFileDialog1.ShowDialog() = DialogResult.OK Then
Direccion = openFileDialog1.FileName

TextBox1.Text = Direccion

MandarMensaje("close archivowav")
MandarMensaje("open " & Direccion & " type waveaudio alias
archivowav")
MandarMensaje("set archivowav time format milliseconds")
MandarMensaje("status archivowav length")
If Val(Trim(cadena)) <0 Then ' Si dicho tiempo es distinto de 0
ProgressBar1.Minimum = 1
ProgressBar1.Maximum = Val(cadena)
ProgressBar1.Value = 1
Slider1.Minimum = 1
Slider1.Maximum = Val(cadena)
Slider1.Value = 1
End If
Label2.Text = Format(Val(cadena), "MM:SS")
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Timer1.Enabled = True
MandarMensaje("play archivowav from 0")
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
MandarMensaje("status archivowav position")
ProgressBar1.Value = Val(cadena)
Slider1.Value = Val(cadena)
Label2.Text = Format(ProgressBar1.Maximum - Val(cadena), "MM:SS")
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
MandarMensaje("stop archivowav")
Timer1.Enabled = False
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If Button4.Text = "Pausa" Then
MandarMensaje("pause archivowav")
Button4.Text = "Continuar"
Else
MandarMensaje("resume archivowav")
Button4.Text = "Pausa"
End If
End Sub
End Class
Thanks everyone
--
Gracias a todos por colaborar
--
Gracias a todos por colaborar
May 7 '07 #1
1 6874
"César" <César@@discussions.microsoft.comschrieb:
When i use the "MciSendString" always returns a big number instead 0 :
What
it says that there is an error, and so don't play the sound.
[...]
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
Declare Function mciGetErrorString Lib "winmm.dll" Alias
"mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String,
ByVal uLength As Long) As Long
Your declarations are wrong. Use these instead (untested):

\\\
Private Declare Auto Function mciSendString Lib "winmm.dll" ( _
ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, _
ByVal uReturnLength As UInt32, _
ByVal hwndCallback As IntPtr _
) As Int32

Private Declare Auto Function mciGetErrorString Lib "winmm.dll" ( _
ByVal dwError As Int32, _
ByVal lpstrBuffer As String, _
ByVal uLength As UInt32 _
) As Int32
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeroen van Vliet | last post by:
I made a program where wav files will be played from the database, with the full path.LIKE i = mciSendstring(open d:\sound.wav type waveaudio",0&,0,0) i = mciSendstring(play d:\sound.wav...
0
by: FRANCO | last post by:
Hello I need an help. I'm using MCI api to manage a video player. I know how to open a video , play it, stop it etc... and I know how to direct video on a pictureBox, but I'm not able get the...
0
by: han.phony | last post by:
Hi, I am trying to intercept the message sent back by winmm.dll's mciSendString method when playback is finished. I tried to override the WndProc in the form but I didn't get/intercept the...
3
by: Dennis | last post by:
I am trying to use the Notify Flag to send a message when a song is finished playing. I got it to work by setting up a dummy window and overriding it's WndProc procedure then raising an event in...
3
by: Mark Denardo | last post by:
Does anyone have any good VB.NET example code that shows how to use the NOTIFY option using the mciSendString API and then handle the return value. The only examples I can find show the VB way...
0
by: kbodily | last post by:
Hi, I have this code in a dragdrop routine for a listview to get the duration of an mp3, where fPath is the path to the file that gets dropped Dim fname As String = Chr(34) + Trim(fPath) +...
2
by: BigC | last post by:
I am using the following line of code to save a voice file (.wav) to disk and it works fine when the filename contains no spaces. However the file doesn't get saved when its name contains a space....
1
by: _nabuchodonozor | last post by:
HI The mciSendString returns different value of tracks length than winamp. The value is longer about 20 seconds and I don't know why. Here is a code: public void SetTime() // I tried to set...
1
by: bajunaid | last post by:
Hi.. I'm trying to use mciSendString to play MP3 files and record WAV using mciSendString.. I did it successfully in a C# windowsApplicaton.. But when I move the same cod to my ASP file.. It...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.