Bonjour à tous,

Je suis en train de faire un projet en C#, sous Visual Studio 2010 Ultimate, et j'ai une solution (dont le nom est TagID3Lib) contenant 2 projets.

Voici le code de mon projet TagID3Lib (projet de type "Bibliothèque de classes) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Fichier DefMedia.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
 
namespace TagID3Lib
{
        class DefMedia
        {
            private string p;
 
 
            public string Titre { get; set; }
            public string Album { get; set; }
            public string Artiste { get; set; }
            public string URI { get; set; }
            public string Annee { get; set; }
            public string Type { get; set; }
            public string Genre { get; set; }
            public string Commentaire { get; set; }
 
            /*
             * Constructeur
             * parametres : string uri - Le chemine du fichier contenant le tag ID3v2 à extraire
             */
            public DefMedia(string uri)
            {
                this.URI = uri;
                chargeMediaDepuisTagID3(uri);
            }
 
            /*
             * Fonction chargeMediaDepuisTagID3
             * parametres : string filePath - Le chemin du fichier contenant le tag ID3v2 à extraire
             * 
             * Cette fonction rempli les properties de la classe DefMedia
             */
            private void chargeMediaDepuisTagID3(string filePath)
            {
                using (FileStream fs = File.OpenRead(filePath))
                {
                    if (fs.Length >= 128)
                    {
                        MusicID3Tag tag = new MusicID3Tag();
                        fs.Seek(-128, SeekOrigin.End);
                        fs.Read(tag.TAGID, 0, tag.TAGID.Length);
                        fs.Read(tag.Title, 0, tag.Title.Length);
                        fs.Read(tag.Artist, 0, tag.Artist.Length);
                        fs.Read(tag.Album, 0, tag.Album.Length);
                        fs.Read(tag.Year, 0, tag.Year.Length);
                        fs.Read(tag.Comment, 0, tag.Comment.Length);
                        fs.Read(tag.Genre, 0, tag.Genre.Length);
                        string theTAGID = Encoding.Default.GetString(tag.TAGID);
 
                        if (theTAGID.Equals("TAG"))
                        {
                            Titre = Encoding.Default.GetString(tag.Title);
                            Artiste = Encoding.Default.GetString(tag.Artist);
                            Album = Encoding.Default.GetString(tag.Album);
                            Annee = Encoding.Default.GetString(tag.Year);
                            Commentaire = Encoding.Default.GetString(tag.Comment);
                            Genre = Encoding.Default.GetString(tag.Genre);
 
                            /* DEBUG */
                            /*
                                Console.WriteLine(Titre);
                                Console.WriteLine(Artiste);
                                Console.WriteLine(Album);
                                Console.WriteLine(Annee);
                                Console.WriteLine(Commentaire);
                                Console.WriteLine(Genre);
                                Console.WriteLine();
                                Console.ReadLine();
                            */
                        }
                    }
                }
            }
 
        }
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Fichier MusicID3Tag.cs
namespace TagID3Lib
{
 
    class MusicID3Tag
    {
 
        public byte[] TAGID = new byte[3];      //  3
        public byte[] Title = new byte[30];     //  30
        public byte[] Artist = new byte[30];    //  30 
        public byte[] Album = new byte[30];     //  30 
        public byte[] Year = new byte[4];       //  4 
        public byte[] Comment = new byte[30];   //  30 
        public byte[] Genre = new byte[1];      //  1
 
    }
}
Ensuite j'ai un autre projet, ImportTag (de type application console) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TagID3Lib;
namespace ImportTag
{
    class Program
    {
        static void Main(string[] args)
        {
 
            string uri = @"D:\chanson.mp3";
            DefMedia m = new DefMedia(uri);
 
        }
    }
}
Rien qu'ici, j'ai des erreurs de la part de Visual Studio qui me dit que
TagID3Lib.DefMedia en contient pas de constructeur qui accepte des arguments 1
Une idée ? J'ai peu d'expérience en C# mais je suis à l'aise en POO en général.

Merci d'avance !