Class: TagLib::FLAC::File

Inherits:
TagLib::File show all
Defined in:
docs/taglib/flac.rb

Overview

The file class for .flac files.

Note that Xiph comments is the primary tagging format for FLAC files. When saving a file, if there's not yet a Xiph comment, it is created from existing ID3 tags. ID3 tags will be updated if they exist, but not created automatically.

Examples:

Reading Xiph comments

TagLib::FLAC::File.open("file.flac") do |file|
  tag = file.xiph_comment
  puts tag.title
  fields = tag.field_list_map
  puts fields['DATE']
end

Adding a picture

TagLib::FLAC::File.open("file.flac") do |file|
  pic = TagLib::FLAC::Picture.new
  pic.type = TagLib::FLAC::Picture::FrontCover
  pic.mime_type = "image/jpeg"
  pic.description = "desc"
  pic.width = 90
  pic.height = 90
  pic.data = File.open("cover.jpg", 'rb') { |f| f.read }

  file.add_picture(pic)
  file.save
end

Since:

  • 0.5.0

Constant Summary collapse

NoTags =

Since:

  • 0.5.0

0x0000
XiphComment =

Since:

  • 0.5.0

0x0001
ID3v1 =

Since:

  • 0.5.0

0x0002
ID3v2 =

Since:

  • 0.5.0

0x0004
AllTags =

Since:

  • 0.5.0

0xffff

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TagLib::File

#close, #save

Constructor Details

#initialize(filename, read_properties = true) ⇒ File

Load a FLAC file.

Parameters:

  • filename (String)
  • read_properties (Boolean) (defaults to: true)

    if audio properties should be read

Since:

  • 0.5.0


53
54
# File 'docs/taglib/flac.rb', line 53

def initialize(filename, read_properties=true)
end

Class Method Details

.open(filename, read_properties = true) {|file| ... } ⇒ Object

Creates a new file and passes it to the provided block, closing the file automatically at the end of the block.

Note that after the block is done, the file is closed and all memory is released for objects read from the file (basically everything from the TagLib namespace).

Using open is preferable to using new and then manually close.

Parameters:

  • filename (String)
  • read_properties (Boolean) (defaults to: true)

    if audio properties should be read

Yields:

Returns:

  • the return value of the block

Since:

  • 0.5.0


45
46
# File 'docs/taglib/flac.rb', line 45

def self.open(filename, read_properties=true)
end

Instance Method Details

#add_picture(picture) ⇒ void

This method returns an undefined value.

Add a picture to the file.

Parameters:

Since:

  • 0.5.0


110
111
# File 'docs/taglib/flac.rb', line 110

def add_picture(picture)
end

#audio_propertiesTagLib::FLAC::Properties

Returns audio properties.

Returns:

Since:

  • 0.5.0


83
84
# File 'docs/taglib/flac.rb', line 83

def audio_properties
end

#id3v1_tagTagLib::ID3v1::Tag

Returns the ID3v1 tag.

Returns:

Since:

  • 0.5.0


71
72
# File 'docs/taglib/flac.rb', line 71

def id3v1_tag
end

#id3v1_tag?Boolean

Returns Whether or not the file on disk actually has an ID3v1 tag.

Returns:

  • (Boolean)

    Whether or not the file on disk actually has an ID3v1 tag.

Since:

  • 1.0.0


131
132
# File 'docs/taglib/flac.rb', line 131

def id3v1_tag?
end

#id3v2_tagTagLib::ID3v2::Tag

Returns the ID3v2 tag.

Returns:

Since:

  • 0.5.0


77
78
# File 'docs/taglib/flac.rb', line 77

def id3v2_tag
end

#id3v2_tag?Boolean

Returns Whether or not the file on disk actually has an ID3v2 tag.

Returns:

  • (Boolean)

    Whether or not the file on disk actually has an ID3v2 tag.

Since:

  • 1.0.0


137
138
# File 'docs/taglib/flac.rb', line 137

def id3v2_tag?
end

#picture_listArray<TagLib::FLAC::Picture>

Returns an array of the pictures attached to the file.

Returns:

Since:

  • 0.5.0


89
90
# File 'docs/taglib/flac.rb', line 89

def picture_list
end

#remove_picture(picture) ⇒ Object

Remove the specified picture.

Parameters:

Since:

  • 1.0.0


97
98
# File 'docs/taglib/flac.rb', line 97

def remove_picture(picture)
end

#remove_picturesvoid

This method returns an undefined value.

Remove all pictures.

Since:

  • 0.5.0


103
104
# File 'docs/taglib/flac.rb', line 103

def remove_pictures
end

#strip(tags = TagLib::FLAC::File::AllTags) ⇒ void

This method returns an undefined value.

Remove the tags matching the specified OR-ed types.

Parameters:

  • tags (int) (defaults to: TagLib::FLAC::File::AllTags)

    The types of tags to remove.

Since:

  • 1.0.0


119
120
# File 'docs/taglib/flac.rb', line 119

def strip(tags=TagLib::FLAC::File::AllTags)
end

#tagTagLib::Tag

Returns the union of the Xiph comment, ID3v1 and ID3v2 tag.

Returns:

Since:

  • 0.5.0


59
60
# File 'docs/taglib/flac.rb', line 59

def tag
end

#xiph_commentTagLib::Ogg::XiphComment

Returns the Xiph comment tag.

Returns:

Since:

  • 0.5.0


65
66
# File 'docs/taglib/flac.rb', line 65

def xiph_comment
end

#xiph_comment?Boolean

Returns Whether or not the file on disk actually has a XiphComment.

Returns:

  • (Boolean)

    Whether or not the file on disk actually has a XiphComment.

Since:

  • 1.0.0


125
126
# File 'docs/taglib/flac.rb', line 125

def xiph_comment?
end