|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
CLASSE MP3 (TAGS, IMAGE)
Information sur la source
Description
Cette classe permet de: - lire les tags mp3 (v1 uniquement) - récupérer sur fnac.com l'image correspondant (en fonction des tags)
Source
- Imports System.IO
- Imports System.Net
-
- <Serializable()> Public Class cls_mp3tag
-
- Public path As String
- Public directory As String
- Public filename As String
- Public artist As String
- Public title As String
- Public album As String
- Public genre As String = 255
- Public comments As String
- Public track As String
- Public tagged As Boolean
- Public num As Integer
-
- ' Genres
- Public Enum enum_genres As Byte
- Blues = 0
- ClassicRock = 1
- Country = 2
- Dance = 3
- Disco = 4
- Funk = 5
- Grunge = 6
- HipHop = 7
- Jazz = 8
- Metal = 9
- NewAge = 10
- Oldies = 11
- Other = 12
- Pop = 13
- RnB = 14
- Rap = 15
- Reggae = 16
- Rock = 17
- Techno = 18
- Industrial = 19
- Alternative = 20
- Ska = 21
- DeathMetal = 22
- Pranks = 23
- Soundtrack = 24
- EuroTechno = 25
- Ambient = 26
- TripHop = 27
- Vocal = 28
- JazzFunk = 29
- Fusion = 30
- Trance = 31
- Classical = 32
- Instrumental = 33
- Acid = 34
- House = 35
- Game = 36
- SoundClip = 37
- Gospel = 38
- Noise = 39
- AlternRock = 40
- Bass = 41
- Soul = 42
- Punk = 43
- Space = 44
- Meditative = 45
- InstrumentalPop = 46
- InstrumentalRock = 47
- Ethnic = 48
- Gothic = 49
- Darkwave = 50
- TechnoIndustrial = 51
- Electronic = 52
- PopFolk = 53
- Eurodance = 54
- Dream = 55
- SouthernRock = 56
- Comedy = 57
- Cult = 58
- Gangsta = 59
- Top40 = 60
- ChristianRap = 61
- PopFunk = 62
- Jungle = 63
- NativeAmerican = 64
- Cabaret = 65
- NewWave = 66
- Psychadelic = 67
- Rave = 68
- Showtunes = 69
- Trailer = 70
- LoFi = 71
- Tribal = 72
- AcidPunk = 73
- AcidJazz = 74
- Polka = 75
- Retro = 76
- Musical = 77
- RocknRoll = 78
- HardRock = 79
- None = 255
- End Enum
-
- '******************************************************************************
- 'recup les infos a partir des tags
- Public Sub init(ByVal e_path As String)
-
- Me.path = e_path
-
- Try
-
- Me.filename = Me.path.Substring(Me.path.LastIndexOf("\") + 1)
- Me.title = Me.filename
- Me.directory = Me.path.Substring(0, Me.path.LastIndexOf("\") + 1)
-
- Dim Buffer(128) As Byte
- Dim StreamReadWrite As System.IO.FileStream
- Dim Encodeur As New System.Text.ASCIIEncoding
- Try
- StreamReadWrite = New System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite)
- Catch ex As Exception
- Exit Sub
- End Try
-
- Dim TagID3 As String
- StreamReadWrite.Seek(-128, System.IO.SeekOrigin.End)
- StreamReadWrite.Read(Buffer, 0, 128)
- TagID3 = Encodeur.GetString(Buffer)
- 'Recherche du Tag TAG
- If TagID3.Substring(0, 3).Equals("TAG") Then
- 'Initialisation de Title
- Me.title = TagID3.Substring(3, 30).Trim.Replace(Chr(0), "").Trim(CChar(vbNullChar))
- 'Initialisation de Author
- Me.artist = TagID3.Substring(33, 30).Trim.Trim.Replace(Chr(0), "").Trim(CChar(vbNullChar))
- 'Initialisation de Album
- Me.album = TagID3.Substring(63, 30).Trim.Trim.Replace(Chr(0), "").Trim(CChar(vbNullChar))
- 'Initialisation de Comments
- Me.comments = TagID3.Substring(97, 28).Trim.Trim.Replace(Chr(0), "").Trim(CChar(vbNullChar))
- 'Analyse du caractère 125 de TagID3
- If TagID3.Chars(125).Equals(0) Then
- 'Initialisation de Track
- Me.track = Buffer.GetValue(126)
- 'Initialisation de Tagged
- Me.tagged = False
- Else
- 'Initialisation de Track
- Me.track = 0
- 'Initialisation de Category
- Me.genre = Buffer.GetValue(127)
- If Me.genre = "" Or Me.genre = " " Then
- Me.genre = "255"
- End If
- If Me.title = "" Then Me.title = Me.filename
- 'Initialisation de Tagged
- Me.tagged = True
-
- 'ferme le fichier
- StreamReadWrite.Close()
-
- End If
- End If
- Catch IOex As System.IO.IOException
-
- End Try
-
-
- 'si ya pas de title, on met le nom du fichier
- If Me.title = "" Then Me.title = Me.filename
-
- 'si ya pas d'artiste, on met le nom du dossier
- If IsNothing(Me.artist) OrElse Me.artist.Length = 0 Then Me.artist = "Inconnu"
-
- End Sub
-
- '******************************************************************************
- 'recup l'image sur le site de la fnac :p
- Public Function get_picture(ByRef e_http As cls_http) As Image
- Try
- 'envoi du formulaire avec les infos
- Dim requete_http As String
- Dim response_http As String
- requete_http = "http://www3.fnac.com/search/quick.do?text=" & Me.artist & " " & Me.title & " " & Me.album & "+&category=audio"
- response_http = e_http.get_url(requete_http)
-
- 'recup le lien pour l'image
- Dim pos_debut As Integer = response_http.IndexOf("http://multimedia.fnac.com/multimedia/images_produits/petites")
- Dim pos_Fin As Integer = response_http.IndexOf("""", pos_debut)
- Dim url_img As String = response_http.Substring(pos_debut, pos_Fin - pos_debut)
- url_img = url_img.Replace("petites", "grandes")
- Debug.WriteLine(url_img)
-
- 'enregistre l'image dans un fichier
- Return e_http.get_picture(url_img)
-
- Catch ex As Exception
- Debug.WriteLine("Erreur lors de la récupération de l'image: " & ex.Message)
- Return Nothing
- End Try
-
- End Function
-
- End Class
-
Imports System.IO
Imports System.Net
<Serializable()> Public Class cls_mp3tag
Public path As String
Public directory As String
Public filename As String
Public artist As String
Public title As String
Public album As String
Public genre As String = 255
Public comments As String
Public track As String
Public tagged As Boolean
Public num As Integer
' Genres
Public Enum enum_genres As Byte
Blues = 0
ClassicRock = 1
Country = 2
Dance = 3
Disco = 4
Funk = 5
Grunge = 6
HipHop = 7
Jazz = 8
Metal = 9
NewAge = 10
Oldies = 11
Other = 12
Pop = 13
RnB = 14
Rap = 15
Reggae = 16
Rock = 17
Techno = 18
Industrial = 19
Alternative = 20
Ska = 21
DeathMetal = 22
Pranks = 23
Soundtrack = 24
EuroTechno = 25
Ambient = 26
TripHop = 27
Vocal = 28
JazzFunk = 29
Fusion = 30
Trance = 31
Classical = 32
Instrumental = 33
Acid = 34
House = 35
Game = 36
SoundClip = 37
Gospel = 38
Noise = 39
AlternRock = 40
Bass = 41
Soul = 42
Punk = 43
Space = 44
Meditative = 45
InstrumentalPop = 46
InstrumentalRock = 47
Ethnic = 48
Gothic = 49
Darkwave = 50
TechnoIndustrial = 51
Electronic = 52
PopFolk = 53
Eurodance = 54
Dream = 55
SouthernRock = 56
Comedy = 57
Cult = 58
Gangsta = 59
Top40 = 60
ChristianRap = 61
PopFunk = 62
Jungle = 63
NativeAmerican = 64
Cabaret = 65
NewWave = 66
Psychadelic = 67
Rave = 68
Showtunes = 69
Trailer = 70
LoFi = 71
Tribal = 72
AcidPunk = 73
AcidJazz = 74
Polka = 75
Retro = 76
Musical = 77
RocknRoll = 78
HardRock = 79
None = 255
End Enum
'******************************************************************************
'recup les infos a partir des tags
Public Sub init(ByVal e_path As String)
Me.path = e_path
Try
Me.filename = Me.path.Substring(Me.path.LastIndexOf("\") + 1)
Me.title = Me.filename
Me.directory = Me.path.Substring(0, Me.path.LastIndexOf("\") + 1)
Dim Buffer(128) As Byte
Dim StreamReadWrite As System.IO.FileStream
Dim Encodeur As New System.Text.ASCIIEncoding
Try
StreamReadWrite = New System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite)
Catch ex As Exception
Exit Sub
End Try
Dim TagID3 As String
StreamReadWrite.Seek(-128, System.IO.SeekOrigin.End)
StreamReadWrite.Read(Buffer, 0, 128)
TagID3 = Encodeur.GetString(Buffer)
'Recherche du Tag TAG
If TagID3.Substring(0, 3).Equals("TAG") Then
'Initialisation de Title
Me.title = TagID3.Substring(3, 30).Trim.Replace(Chr(0), "").Trim(CChar(vbNullChar))
'Initialisation de Author
Me.artist = TagID3.Substring(33, 30).Trim.Trim.Replace(Chr(0), "").Trim(CChar(vbNullChar))
'Initialisation de Album
Me.album = TagID3.Substring(63, 30).Trim.Trim.Replace(Chr(0), "").Trim(CChar(vbNullChar))
'Initialisation de Comments
Me.comments = TagID3.Substring(97, 28).Trim.Trim.Replace(Chr(0), "").Trim(CChar(vbNullChar))
'Analyse du caractère 125 de TagID3
If TagID3.Chars(125).Equals(0) Then
'Initialisation de Track
Me.track = Buffer.GetValue(126)
'Initialisation de Tagged
Me.tagged = False
Else
'Initialisation de Track
Me.track = 0
'Initialisation de Category
Me.genre = Buffer.GetValue(127)
If Me.genre = "" Or Me.genre = " " Then
Me.genre = "255"
End If
If Me.title = "" Then Me.title = Me.filename
'Initialisation de Tagged
Me.tagged = True
'ferme le fichier
StreamReadWrite.Close()
End If
End If
Catch IOex As System.IO.IOException
End Try
'si ya pas de title, on met le nom du fichier
If Me.title = "" Then Me.title = Me.filename
'si ya pas d'artiste, on met le nom du dossier
If IsNothing(Me.artist) OrElse Me.artist.Length = 0 Then Me.artist = "Inconnu"
End Sub
'******************************************************************************
'recup l'image sur le site de la fnac :p
Public Function get_picture(ByRef e_http As cls_http) As Image
Try
'envoi du formulaire avec les infos
Dim requete_http As String
Dim response_http As String
requete_http = "http://www3.fnac.com/search/quick.do?text=" & Me.artist & " " & Me.title & " " & Me.album & "+&category=audio"
response_http = e_http.get_url(requete_http)
'recup le lien pour l'image
Dim pos_debut As Integer = response_http.IndexOf("http://multimedia.fnac.com/multimedia/images_produits/petites")
Dim pos_Fin As Integer = response_http.IndexOf("""", pos_debut)
Dim url_img As String = response_http.Substring(pos_debut, pos_Fin - pos_debut)
url_img = url_img.Replace("petites", "grandes")
Debug.WriteLine(url_img)
'enregistre l'image dans un fichier
Return e_http.get_picture(url_img)
Catch ex As Exception
Debug.WriteLine("Erreur lors de la récupération de l'image: " & ex.Message)
Return Nothing
End Try
End Function
End Class
Conclusion
C'est un version beta, ya surement plein de bugs mais bon... (titou ma déja permis d'en resoudre :) Autrement je voudrais remercier HVb pour son code sur la recup du source html d'une page web (http://www.vbfrance.com/code.aspx?id=5938) et de téléchargement de fichiers (http://www.vbfrance.com/code.aspx?id=6109) Pour l'utiliser: dim mp3 as new cls_mp3tag() mp3.init(le_chemin_de_votre_mp3) mp3.num = 1 'il doivent avoir un no, moi c'est la clé de ma base access mp3.get_picture(le_dossier_dans_lequel_vous_voulez_l_enregistrer) 'affiche dans un picturebox picturebox1.image=image.fromfile(mp3.img_path) 'affiche les tags dans un textbox textbox1.text = mp3.artist & " - " & mp3.title & " - " & mp3.album Enjoy :)
Historique
- 26 février 2006 17:48:39 :
- Prise en compte des remarques de titou !
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
VB6 lire mp3 [ par DarkFel ]
Bonjour alors voilà j'ai parcourt le site en faisant des recherches et j'ai vu pleins de trucs pour lire un fichier mp3. N'étant pas très doué j'ai pa
commande pour integrer un fichier mp3 dans un projet vb.net 2005 [ par hamzatsdi1A ]
salut a tous bon je suis entrain de developper une application de location de voiture , je veux bien integrer une chanson mais je n'arrive pas a le fa
Conversion fichier Wave vers MP3 en VB? [ par nabilG ]
Quelqu'un aurait-il essayé de convertir un fichier WAVE enregistré en fichier MP3 en utilisant le VB6 ou VB.NET?J'ai trouvé des exemples d'enregistrem
stéganographie MP3/4 [ par kalif ]
bonjour, es ce qu'il y a quelqu'un qui sais comment faire de la stéganographie dans un fichier mp3 ou mp4, c'est a dire cacher un fichier (de n'import
Convertir .WAV en .MP3 [ par Supersnifeur ]
Hello,J'aimerais savoir si quelqu'un peut me passer un script pour la convertion de l'extension .wav en .mp3 .Je galere depuis au moins une semaine po
VB6 - Lire mp3 en boucle avec MMControl [ par Airel35 ]
Bonjour,Tout est dans le titre. En fait sur chaque form j'ai un son différent, mais l'utilisateur peut rester sur ce form des heures s'il le souhaite,
Insérer du Texte dans un DataGrid: Lecteur MP3 [ par xboxnissan ]
Bonjour a tous et a toute,Peut-être le thème ne se situe pas la,J'ai une question à vous poser.Ça fais près de 1 semaine aujourd'hui que je cherche un
Dir [ par mr404 ]
Bonjour à tousJe suis en vb6 j'utilise une fonction random pour un lecteur multimedia et j'utilise la fonction Dir&un morceau du code : Trac
Gérer les sorties audio [ par scorpion 3180 ]
Bonjour à tous,Je développe pour l'entreprise où j'effectue mon stage une application qui devra lire differants fichiers mp3 en même temps et sur diff
Vu Meter [ par rejean ]
Bonjour a tous, je suis nouveau en programation Visual Basic 6. C'est ma deuxieme demande d'aide sur ce forum. Cette fois ci c'est au suget de capture
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|