Les Snippets

Connexion

Jouer et arrêter un son wav

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 25/03/2006 16:58:54 et initié par Willi [Liste]
Date de mise à jour : 09/08/2006 23:10:50
Vue : 22802
Catégorie(s) : Multimédia
Langages dispo pour ce code :
- VB6, VBA
- VB 2005
- C# 2.x
- VB 2005, VB.NET 1.x
- C
- Delphi 5
- Java
- VB.NET 1.x
- VB.NET 1.x
- C++ .NET 2.x
- VBScript
- Voir tous les langages pour ce code snippet



Langage : VB.NET 1.x
Date ajout : 20/11/2006
Posté par OneHacker [Liste]
Public Class SoundClass
    Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
    As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
    ' name specifies the sound file when the SND_FILENAME flag is set.
    ' hmod specifies an executable file handle.
    ' hmod must be Nothing if the SND_RESOURCE flag is not set.
    ' flags specifies which flags are set. 
    ' The PlaySound documentation lists all valid flags.
    Private Const SND_SYNC As Long = 0          ' play synchronously
    Public Const SND_ASYNC As Long = 1         ' play asynchronously
    Public Const SND_FILENAME = &H20000  ' name is file name 8192(10)
    Public Const SND_RESOURCE = &H40004  ' name is resource name or atom
    Private Const SND_LOOP = &H8 ' Répète le son jusqu'au prochain appel de PlaySound
    Private Const SND_MEMORY = 4 ' Enregistre en mémoire l'image du son
    Private Const SND_STOP As Long = 64 ' Stop la lecture du fichier
    Private Const SND_NODEFAULT As Long = 2 ' Ne joue pas
    Private Const SND_NOWAIT As Long = 8192 ' Pas d'attente
    Public Shared FileName As String
    Public Enum ReadMode
        Synchronously = SND_SYNC ' Exécuté sans thread ' (fait ramer)
        Asynchronously = SND_ASYNC ' Exécuté avec thread (éxécution fluide)
    End Enum
    Public Shared Sub PlaySoundFile(ByVal FileName As String, ByVal ReadMode As ReadMode)
        ' Plays a sound from filename.
        PlaySound(FileName, Nothing, ReadMode)
    End Sub
    Public Shared Sub StopSoundFile(ByVal FileName As String, ByVal ReadMode As ReadMode)
        ' Stops a sound from filename.
        PlaySound(String.Empty, Nothing, SND_STOP)
    End Sub
    Public Shared Sub PlaySoundFileLoop(ByVal FileName As String, ByVal ReadMode As ReadMode)
        '' Plays a soundloop from filename.
        PlaySound(FileName, Nothing, ReadMode Or SND_LOOP)
    End Sub
    Public Shared Function GetSoundWavePicture() As Image
        ' Plays a sound from filename.
        PlaySound(String.Empty, Nothing, SND_MEMORY)
        Return Clipboard.GetDataObject.GetData(DataFormats.Bitmap, True)
    End Function
End Class

Snippets en rapport avec : Audio, Jouer, Arreter, Wav, Son



Codes sources en rapport avec : Audio, Jouer, Arreter, Wav, Son

{Visual Basic, VB6, VB.NET, VB 2005} JOUER DU SON EN DUR (DIRECTX8)
C'est un exemple très simple de l'utilisation de la methode Writebuffer de directsound. J'ai posté c...

{JAVA / J2EE} POUR LIRE DU SON
Pour lire des fichiers sons. Fonctionnent avec le wav, au, midi, et quelques autres. Pour fonctionne...

{Visual Basic, VB6, VB.NET, VB 2005} LECTURE DES CHIFFRES D'UN TEXTE (LECTURE ROBOTIQUE)
Salut, voici un petit code qui pourrait être util pour ceux qui font des logiciels de gestion de pay...

{C / C++ / C++.NET} CONTROLEUR DE VOLUME SONORE EN C [ API WINDOWS ]
Controleur de volume sonore en C --------------------------------------- Programmé avec API Wind...

{C / C++ / C++.NET} MPEG AUDIO -> WAVE FILE (DEV-C++)
Mpeg Audio -> Wave File : Cette source vous permet de convertir un fichier mpeg audio tel que le m...

{JAVA / J2EE} PROGRAMME COMPLET D'AIDE À L'APPRENTISSAGE DE TEXTE
Ce logiciel est terminé mais pas parfait, des petites choses peuvent encore être ajoutées, modifiée....

{IRC} PLAYSIMU
ce petit bout de code vous permet de jouer plusieurs sons wav ou mp3 en même temps. Ceci peut être ...

{C / C++ / C++.NET} AJOUT D'ECHO SUR DES FICHIERS WAVS
Ce petit programme permet de rajouter de l'echo sur vos fichiers WAVs. Le format d'entrée des fic...

{Visual Basic, VB6, VB.NET, VB 2005} MCI L'ENREGISTREMENT DU SON
Salut! Tous simplement il enregistre le son depuis le microphone ou l'ordinateur ou depuis un fichi...

{Visual Basic, VB6, VB.NET, VB 2005} ENCODEUR CDA VERS MP3 OU WAV
Bon voila un petit programme qui vous permet de ripper vos CD audio (transformation cda vers mp3 ou ...