2011-08-29 2 views
1

MP3 파일에 아트 워크를 쓰는 데 문제가 있습니다. Taglib-sharp를 사용하여 MP3 파일의 모든 아트웍을 읽고 표시 할 수 있지만 MP3 태그에 두 개 이상의 그림 (예 : FrontCover 및 BackCover)을 삽입 할 때 문제가 있습니다. 그것. 만약 그것이 하나의 삽화라면 ... 할 수 있어요 누군가 나를 뼈다귀로 던져주고 어떻게 할 수 있겠습니까? (vb.net은 훌륭하지만 C#도 트릭을 수행합니다.).Net에서 Taglib-sharp 2.0.4.0으로 ArtWork를 작성하는 데 문제가 있습니다.

한 번 더 요청 ... mp3 태그 안의 이미지를 삭제 하시겠습니까 ?? 누군가 나에게 그것을하는 방법에 대한 모범을 보여 주실 수 있습니까?

도움 주셔서 감사합니다.

답변

4

어떻게 이미지를 삽입 및 제거 하시겠습니까? 코드를 게시 할 수 있습니까?

모든 태그는 IPicture 인터페이스와 Tag.Pictures getter 및 setter를 사용하여 작동합니다. Tag.Pictures 배열의 내용을 수정하면 파일에 아무런 영향을주지 않으므로 기존 목록을 수정하면 현재 값을 가져 와서 조작하고 다시 설정해야합니다. 단순히 그림을 설정하거나 지우는 것이 더 쉽습니다. 당신은 다음과 같이 태그에서 모든 이미지를 제거 할 수 있습니다

IPicture pictures = new IPicture[1]; 
pictures[0] = new Picture("path/to/picture.jpg"); 
file.Tag.Pictures = pictures; 

:

당신과 함께 하나의 이미지를 가지고 파일을 설정할 수 있습니다

file.Tag.Pictures = new IPicture[0]; 
file.Save(); 

조작 또는 더 복잡하지만 같은 다음 사고의 라인. Tag.Pictures가 배열 대신 IEnumerable 인 경우 더 좋았지 만 완료된 작업은 완료되었습니다. 내 MP3 태그의 응용 프로그램에 다음과 같은 태그 라이브러리 날카로운 코드를 사용하고 https://github.com/mono/taglib-sharp/blob/master/examples/SetPictures.cs

1

:

다음은 명령 줄 인수 이미지를 설정하는 예제 프로그램입니다. 'mime'과 'type'을 설정하지 않고 Windows/WMP가 올바르게 표시하더라도 Artwork을 iTunes에서 표시하고 이후 iPod에서 표시 할 수 없었습니다.

TagLib.File targetFileMp3Tag = TagLib.File.Create(...); 

Picture picture = new Picture(); 
picture.Type = PictureType.Other; 
picture.MimeType = "image/jpeg"; 
picture.Description = "Cover";   
picture.Data = ByteVector.FromStream(...); 

targetFileMp3Tag.Tag.Pictures = new IPicture[1] { picture }; 
targetFileMp3Tag.save() 

HTH는

4

나는 바비 밤라과 같은 문제를 가로 질러왔다. 나는 아이튠즈가 UTF-16을 싫어한다는 것을 발견했다.

targetMp3File = TagLib.File.Create(...); 

// define picture 
TagLib.Id3v2.AttachedPictureFrame pic = new TagLib.Id3v2.AttachedPictureFrame(); 
pic.TextEncoding = TagLib.StringType.Latin1; 
pic.MimeType  = System.Net.Mime.MediaTypeNames.Image.Jpeg; 
pic.Type   = TagLib.PictureType.FrontCover; 
pic.Data   = TagLib.ByteVector.FromPath(...); 

// save picture to file 
targetMp3File.Tag.Pictures = new TagLib.IPicture[1] { pic };  
targetMp3File.Save(); 

기본적으로 전체 내용은 pic.TextEncoding 행에 있습니다. 또한 .NET 상수를 통해 MIME 형식을 할당했습니다.

결과적으로 설명을 사용하는 TagLib.PictureType.Other 또는 해결 방법이 필요하지 않습니다. 내 솔루션의 유일한 단점은 MP3 파일에 대해서만 올바르게 작동한다는 것입니다.

1

Taglib 버전 2.1.0.0을 사용하고 있으며 아직까지이 버전에 대한 설명서가 없습니다. 내가 함께 ...

Private Sub SetTags() 
    Me.Cursor = Cursors.WaitCursor 

    'Set the version and force it. 
    TagLib.Id3v2.Tag.DefaultVersion = 3 
    TagLib.Id3v2.Tag.ForceDefaultVersion = True 

    'Set all standard tags. 
    strInput = Trim(txtMP3Input.Text) 
    strTitle = Trim(txtTitle.Text) 
    strArtist = Trim(txtArtist.Text) 
    strAlbumArtist = Trim(txtAlbumArtist.Text) 
    strAlbum = Trim(txtAlbum.Text) 
    intYear = Convert.ToInt32(Val(cmbDate.SelectedItem)) 
    strGenre = cmbGenre.SelectedItem 
    strComments = Trim(txtComment.Text) 
    strArt = Trim(txtAlbumArt.Text) 

    'Create a file (mp3) 
    Dim fName As TagLib.File = TagLib.File.Create(strInput) 

    'Set the Album art. 
    Dim pics As Picture = New Picture(strArt) 

    'Insert the standard tags. 
    fName.Tag.Title = strTitle 
    fName.Tag.Performers = New String() {strArtist} 
    fName.Tag.AlbumArtists = New String() {strAlbumArtist} 
    fName.Tag.Album = strAlbum 
    fName.Tag.Year = intYear 
    fName.Tag.Genres = New String() {strGenre} 
    fName.Tag.Comment = strComments 

    'Insert Album art and 
    ' save to file and dispose. 
    Dim picsFrame As New TagLib.Id3v2.AttachedPictureFrame(pics) 
    picsFrame.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg 

    'set the type of picture (front cover) 
    picsFrame.Type = TagLib.PictureType.FrontCover 

    'Id3v2 allows more than one type of image, just one is needed here. 
    Dim pictFrames() As TagLib.IPicture = {picsFrame} 

    'set the pictures in the tag 
    fName.Tag.Pictures = pictFrames 

    fName.Save() 
    fName.Dispose() 

    Me.Cursor = Cursors.Default 
    lblSuccess.Text = "Tags Set Successfully." 
End Sub 

내가 비주얼 스튜디오 2012 사용을 던졌다 사용하여이 버전을 설치 해낸 그래서 사실은이 버전 을했다 무언가를 찾기 위해 모든 대답을 검색하려면 여기를 올 수밖에 없었어이있다 메뉴 항목 도구 -> 라이브러리 패키지 관리자 -> 패키지 관리자 콘솔."PM>"프롬프트에서 'Install-Package taglib'을 입력하면 응용 프로그램에 Taglib-Sharp 패키지가 추가됩니다. 이것은 실제로 Power Shell에 대한 명령 행 유틸리티입니다. 잠시만 기다리면 갈 준비가 된 것입니다.

+0

감사합니다. 'picsFrame.Description = ""'을 추가해야합니다. 그렇지 않으면 아트웍의 원래 위치가 mp3 파일에 저장됩니다. –

관련 문제