Guest jason76 Posted May 14, 2004 Report Share Posted May 14, 2004 this is all a over my head to be honest as i make biscuits in my job :oops: could someone tell me how to make a music file play. got a timer thing working on phone i think.eg.if label1.text= 0 'then play a music file, and what is the timer interval to countdown in seconds.any help would be nice :?: Link to comment Share on other sites More sharing options...
Guest ChrisJM Posted May 20, 2004 Report Share Posted May 20, 2004 ok, you need to get a file for sound, i can pm it to you if you like :) and you will just need to define a new sound and play it (i can explain how in a pm if you like?) Link to comment Share on other sites More sharing options...
Guest Brody Posted May 26, 2004 Report Share Posted May 26, 2004 Chris, the point of a forum is to share knowledge so describe it here! :) Link to comment Share on other sites More sharing options...
Guest MECX Posted May 29, 2004 Report Share Posted May 29, 2004 yeh chris you have been told before--now share the wealth :-D :-D Link to comment Share on other sites More sharing options...
Guest great Posted June 14, 2004 Report Share Posted June 14, 2004 anyone has a solution on this... :?: :idea: :?: i've been looking it all over the internet but still no luck :oops: thank you Link to comment Share on other sites More sharing options...
Guest bosshogg Posted June 14, 2004 Report Share Posted June 14, 2004 Here's a sample in c#, hope this is what you're on about... using System; using System.Runtime.InteropServices; using System.IO; namespace MyNamespace { /// <summary> /// Summary description for MyClass. /// </summary> public class MyClass { [DllImport("CoreDll.DLL", EntryPoint="PlaySound", SetLastError=true)] private extern static int WCE_PlaySound(string szSound, IntPtr hMod, int flags); [DllImport("CoreDll.DLL", EntryPoint="PlaySound", SetLastError=true)] private extern static int WCE_PlaySoundBytes (byte[] szSound, IntPtr hMod, int flags); public const UInt32 SND_ASYNC = 1; public const UInt32 SND_MEMORY = 4; string m_fileName; byte[] m_soundBytes; // Construct the Sound object to play sound data from the specified file. public MyClass(string fileName) { m_fileName = fileName; } // Construct the Sound object to play sound data from the specified stream. public MyClass(Stream stream) { // read the data from the stream m_soundBytes = new byte [stream.Length]; stream.Read(m_soundBytes, 0,(int)stream.Length); } // Play the sound. public void Play () { // If a file name has been registered, call WCE_PlaySound, // otherwise call WCE_PlaySoundBytes. if (m_fileName != null) WCE_PlaySound(m_fileName, IntPtr.Zero, (int) (SND_ASYNC | SND_FILENAME)); else WCE_PlaySoundBytes (m_soundBytes, IntPtr.Zero, (int) (SND_ASYNC | SND_MEMORY)); } } } then call the class like this: MyClass cls = new MyClass('chime.wav'); cls.Play(); Link to comment Share on other sites More sharing options...
Guest great Posted June 15, 2004 Report Share Posted June 15, 2004 thank you but do you have in for vb.net ?? :? sorry for i don't mention it before! :D Link to comment Share on other sites More sharing options...
Guest bosshogg Posted June 15, 2004 Report Share Posted June 15, 2004 no, sorry mate, I know classic vb but not vb.net...vb.net and c# are quite similar though, if I get a couple of minutes free this morning I'll see if I can convert it. Link to comment Share on other sites More sharing options...
Guest great Posted June 15, 2004 Report Share Posted June 15, 2004 no, sorry mate, I know classic vb but not vb.net...vb.net and c# are quite similar though, if I get a couple of minutes free this morning I'll see if I can convert it. i'll realy appreciate that and believe me you will solve this for many users who are wondering :D thanks!!! :D Link to comment Share on other sites More sharing options...
Guest bosshogg Posted June 15, 2004 Report Share Posted June 15, 2004 ok, here you go, I didn't test playing from a stream but it works with a filename... Public Class SoundPlayer Declare Function PlaySound Lib "CoreDLL.dll" (ByVal szSound As String, _ ByVal hMod As IntPtr, _ ByVal flags As Integer) As Integer Declare Function PlaySoundBytes Lib "CoreDLL.dll" (ByVal szSound As Byte(), _ ByVal hMod As IntPtr, _ ByVal flags As Integer) As Integer <Flags()> _ Public Enum PlaySoundFlags SND_SYNC = 0 SND_ASYNC = 1 SND_FILENAME = &H20000 SND_RESOURCE = &H40004 End Enum Public Function Play(ByVal filename As String) If Len(filename) > 0 Then PlaySound(filename, IntPtr.Zero, PlaySoundFlags.SND_ASYNC Or PlaySoundFlags.SND_FILENAME) End If End Function Public Function Play(ByVal stream As Stream) Dim soundBytes As Byte() If Not stream Is Nothing Then ReDim soundBytes(stream.Length) stream.Read(soundBytes, 0, stream.Length) PlaySoundBytes(soundBytes, IntPtr.Zero, PlaySoundFlags.SND_ASYNC Or PlaySoundFlags.SND_RESOURCE) End If End Function End Class then use Dim cls As SoundPlayer cls = New SoundPlayer cls.Play("chimes.wav") to call it. Hope that helps, look forward to seeing your app! :D Link to comment Share on other sites More sharing options...
Guest bosshogg Posted June 15, 2004 Report Share Posted June 15, 2004 oh and I forgot to include Imports System Imports System.IO Imports System.Runtime.InteropServices which goes above the class declaration. Link to comment Share on other sites More sharing options...
Guest great Posted June 15, 2004 Report Share Posted June 15, 2004 YOU ARE AWESOME!!! i will try it at home and i will post results tomorrow! thousand thanks!!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now