kentmelby Skrevet 30. januar 2009 Del Skrevet 30. januar 2009 hei .... er det noen der ute som kan hjelpe meg... Jeg holder å lage ett program som skal gå på en PDA, jeg bruker Visual Studio 2005 på Vista (har lastet ned alt av servicePack som jeg har kunne funnet) der jeg ønsker å bruke ulike lyder som jeg har lastet inn i prosjektet via Resource Manageren. men jeg får ikke til annet enn ett lite knepp .. ( kan virke som ett kneppet PDA's defaulte lyd i PDA systemet ) er det noen som vet hvorfor eller hva jeg kan gjøre for å spille av lyder i en PDA (ce 5.0) med visual studio 2005 koden min ser ca slik ut (etter mye leting på nettet ) jeg er klar over dette https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=97794 Class SoundClass Enum SoundFlags As Integer SND_SYNC = &H0 ' play synchronously (default) SND_ASYNC = &H1 ' play asynchronously SND_NODEFAULT = &H2 ' silence (!default) if sound not found SND_MEMORY = &H4 ' pszSound points to a memory file SND_LOOP = &H8 ' loop the sound until next sndPlaySound SND_NOSTOP = &H10 ' don't stop any currently playing sound SND_NOWAIT = &H2000 ' don't wait if the driver is busy SND_ALIAS = &H10000 ' name is a registry alias SND_ALIAS_ID = &H110000 ' alias is a predefined ID SND_FILENAME = &H20000 ' name is file name SND_RESOURCE = &H40004 ' name is resource name or atom End Enum ' Declare Function PlaySound Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer Declare Function PlaySound Lib "coredll.dll" (ByVal pszSound As String, ByVal hMod As IntPtr, ByVal sf As SoundFlags) As Boolean Public Sub Play(ByVal fileName As String) 'Shared is the same as static in C# Try Call PlaySound(fileName, System.IntPtr.Size, SoundFlags.SND_MEMORY) Catch MsgBox("Can't play sound file") End Try End Sub end class '----------------------------- ' fra programFormen '----------------------------- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim s As New SoundClass s.PlaySound2("Resources\tada.wav") End Sub kme Lenke til kommentar
Moskus Skrevet 25. februar 2009 Del Skrevet 25. februar 2009 Jeg bruker denne klassen, og det går som det griner: Imports System Imports System.Runtime.InteropServices Imports System.Diagnostics Imports System.Threading Imports System.IO Public Class Sound Private m_soundBytes() As Byte Private m_fileName As String Public Declare Function WCE_PlaySound Lib "CoreDll.dll" Alias "PlaySound" (ByVal szSound As String, ByVal hMod As IntPtr, ByVal flags As Integer) As Integer Public Declare Function WCE_PlaySoundBytes Lib "CoreDll.dll" Alias "PlaySound" (ByVal szSound() As Byte, ByVal hMod As IntPtr, ByVal flags As Integer) As Integer Private Enum Flags SND_SYNC = &H0 ' play synchronously (default) SND_ASYNC = &H1 ' play asynchronously SND_NODEFAULT = &H2 ' silence (!default) if sound not found SND_MEMORY = &H4 ' pszSound points to a memory file SND_LOOP = &H8 ' loop the sound until next sndPlaySound SND_NOSTOP = &H10 ' don't stop any currently playing sound SND_NOWAIT = &H2000 ' don't wait if the driver is busy SND_ALIAS = &H10000 ' name is a registry alias SND_ALIAS_ID = &H110000 ' alias is a predefined ID SND_FILENAME = &H20000 ' name is file name SND_RESOURCE = &H40004 ' name is resource name or atom End Enum ' Construct the Sound object to play sound data from the specified file. Public Sub New(ByVal fileName As String) m_fileName = fileName End Sub ' Construct the Sound object to play sound data from the specified stream. Public Sub New(ByVal stream As Stream) ' read the data from the stream m_soundBytes = New Byte(stream.Length) {} stream.Read(m_soundBytes, 0, Fix(stream.Length)) End Sub 'New ' Play the sound Public Sub Play() ' If a file name has been registered, call WCE_PlaySound, ' otherwise call WCE_PlaySoundBytes. If Not (m_fileName Is Nothing) Then WCE_PlaySound(m_fileName, IntPtr.Zero, Fix(Flags.SND_ASYNC Or Flags.SND_FILENAME)) Else WCE_PlaySoundBytes(m_soundBytes, IntPtr.Zero, Fix(Flags.SND_ASYNC Or Flags.SND_MEMORY)) End If End Sub End Class Brukes slik: Dim startuppath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click Dim sound As New Sound(startuppath & "\drumroll.wav") sound.Play() End Sub Lenke til kommentar
Wubbable Skrevet 25. februar 2009 Del Skrevet 25. februar 2009 Hvorfor ikke bare ha shared subs? Lite vits å ha en New() bare for et filnavn som lett kan passeres til den egentlige funksjonen. Lenke til kommentar
Moskus Skrevet 25. februar 2009 Del Skrevet 25. februar 2009 Det kan du spørre Microsoft om. Lenke til kommentar
GeirGrusom Skrevet 25. februar 2009 Del Skrevet 25. februar 2009 System.Media.SoundPlayer er da vitterlig støttet av Compact Framework... Lenke til kommentar
Moskus Skrevet 25. februar 2009 Del Skrevet 25. februar 2009 I 3.5 ja, ikke 2.0... Lenke til kommentar
GeirGrusom Skrevet 25. februar 2009 Del Skrevet 25. februar 2009 http://msdn.microsoft.com/en-us/library/sy...yer(VS.80).aspx Note: This class is new in the .NET Framework version 2.0. Lenke til kommentar
Moskus Skrevet 25. februar 2009 Del Skrevet 25. februar 2009 I 2.0 ja, ikke 1.0... Lenke til kommentar
GeirGrusom Skrevet 25. februar 2009 Del Skrevet 25. februar 2009 (endret) Det er sant Men hvem sitter i Visual Studio 2005 og skriver Visual Studio 2003 kode? Endret 25. februar 2009 av GeirGrusom Lenke til kommentar
Moskus Skrevet 26. februar 2009 Del Skrevet 26. februar 2009 Jeg holdt meg lenge til 1.0 for Compact Framework fordi det hadde størst kompatibilitet. Det er litt mer mas å legge inn framework på mobil enn på en PC. Men heldigvis ble 2.0 standard i WM6.1 og 3.5 er jo nærmest blitt et must uansett (og følger antakeligvis med WM6.5). Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå