Trop Large... [Résolu]

Signaler
Messages postés
150
Date d'inscription
dimanche 17 mai 2009
Statut
Membre
Dernière intervention
25 mai 2012
-
Messages postés
150
Date d'inscription
dimanche 17 mai 2009
Statut
Membre
Dernière intervention
25 mai 2012
-
Bonjour,
J'ai de la musique a jouer dans mon app, j'ai ajouté le fichier wav dans les resources et ça marche. mais un wav de 3:30 et trop large.
ya t il une solution pour lire un mp3 sans l'ecrite sur le HDD, Oubien comprimé le wave, et le decompressé juste avan de la lecture?

1 réponse

Messages postés
150
Date d'inscription
dimanche 17 mai 2009
Statut
Membre
Dernière intervention
25 mai 2012

Bah un peut de recherche, les api, puis j'ai crée un pti class pour lire les mp3 ^^
voila

'i'm sick of big waves and wmp controls.
'made by Miharbi-DoNo

Public Class Mp3_Player
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Private sAlias As String
Private Filename As String
Private FileType As MediaType
Private FadeEffect As Boolean

Enum MediaType
File
URL
End Enum

ReadOnly Property AliasString() As String
Get
Return Me.sAlias
End Get
End Property
Sub New()
sAlias = ""
Filename = ""
FileType = Nothing
FadeEffect = False
End Sub
Sub New(ByVal Filepath As String, ByVal sAlias As String, ByVal TypeOfMedia As MediaType, Optional ByVal FadeEffect As Boolean = False)
Me.Filename = Filepath
Me.sAlias = sAlias
FileType = TypeOfMedia
Me.FadeEffect = FadeEffect
MP3_Open()
End Sub
Sub MP3_Open()
If FileType = MediaType.File Then
If Not IO.File.Exists(Filename) Then
Exit Sub
End If
Dim Buffer As String = New String(Chr(0), 255)
If GetShortPathName(Filename, Buffer, Buffer.Length) <> 0 Then
Filename = Buffer.Substring(0, Buffer.IndexOf(Chr(0)))
End If
End If
mciSendString("open " & Filename & " type MPEGVideo alias " & sAlias, 0, 0, 0)
End Sub
Sub MP3_Pause()
If Me.Status = "playing" And FadeEffect Then
FadeoutVolume()
Else
SetVolume(100, 100)
End If
mciSendString("pause " & sAlias, 0, 0, 0)
End Sub

Sub MP3_Resume()
If FadeEffect Then
SetVolume(0, 0)
End If
mciSendString("resume " & sAlias, 0, 0, 0)
If FadeEffect Then
FadeinVolume()
Else
SetVolume(100, 100)
End If
End Sub
Sub MP3_Close()
If Me.Status = "playing" And FadeEffect Then
FadeoutVolume()
Else
SetVolume(100, 100)
End If
mciSendString("stop " & sAlias, 0, 0, 0)
mciSendString("close " & sAlias, 0, 0, 0)
End Sub
Sub MP3_Play()
If FadeEffect Then
SetVolume(0, 0)
End If
mciSendString("play " & sAlias & " from 0", 0, 0, 0)
If FadeEffect Then
FadeinVolume()
Else
SetVolume(100, 100)
End If

End Sub
Sub SetVolume(ByVal left As Integer, ByVal right As Integer)
Mp3_Player.mciSendString("setaudio " + sAlias + " right volume to " + (10 * right).ToString, 0, 0, 0)
Mp3_Player.mciSendString("setaudio " + sAlias + " left volume to " + (10 * left).ToString, 0, 0, 0)
End Sub
Sub FadeinVolume()
For i = 0 To 1000 Step 25
Mp3_Player.mciSendString("setaudio " + sAlias + " right volume to " + i.ToString, 0, 0, 0)
Mp3_Player.mciSendString("setaudio " + sAlias + " left volume to " + i.ToString, 0, 0, 0)
Threading.Thread.Sleep(40)
Next
End Sub
Sub FadeoutVolume()
For i = 1000 To 0 Step -25
Mp3_Player.mciSendString("setaudio " + sAlias + " right volume to " + i.ToString, 0, 0, 0)
Mp3_Player.mciSendString("setaudio " + sAlias + " left volume to " + i.ToString, 0, 0, 0)
Threading.Thread.Sleep(40)
Next
End Sub
ReadOnly Property Status() As String
Get
Dim sStatus As String = New String(Chr(0), 255)
mciSendString("Status " & sAlias & " Mode", sStatus, 255, 0)
Return sStatus.Substring(0, sStatus.IndexOf(Chr(0)))
End Get
End Property
Property FadeEffects() As Boolean
Get
Return FadeEffect
End Get
Set(ByVal value As Boolean)
FadeEffect = value
End Set
End Property
End Class