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



51
52
# File 'docs/taglib/flac.rb', line 51

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



43
44
# File 'docs/taglib/flac.rb', line 43

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



108
109
# File 'docs/taglib/flac.rb', line 108

def add_picture(picture)
end

#audio_propertiesTagLib::FLAC::Properties

Returns audio properties.

Returns:

Since:

  • 0.5.0



81
82
# File 'docs/taglib/flac.rb', line 81

def audio_properties
end

#id3v1_tagTagLib::ID3v1::Tag

Returns the ID3v1 tag.

Returns:

Since:

  • 0.5.0



69
70
# File 'docs/taglib/flac.rb', line 69

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



129
130
# File 'docs/taglib/flac.rb', line 129

def id3v1_tag?
end

#id3v2_tagTagLib::ID3v2::Tag

Returns the ID3v2 tag.

Returns:

Since:

  • 0.5.0



75
76
# File 'docs/taglib/flac.rb', line 75

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



135
136
# File 'docs/taglib/flac.rb', line 135

def id3v2_tag?
end

#picture_listArray<TagLib::FLAC::Picture>

Returns an array of the pictures attached to the file.

Returns:

Since:

  • 0.5.0



87
88
# File 'docs/taglib/flac.rb', line 87

def picture_list
end

#remove_picture(picture) ⇒ Object

Remove the specified picture.

Parameters:

Since:

  • 1.0.0



95
96
# File 'docs/taglib/flac.rb', line 95

def remove_picture(picture)
end

#remove_picturesvoid

This method returns an undefined value.

Remove all pictures.

Since:

  • 0.5.0



101
102
# File 'docs/taglib/flac.rb', line 101

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



117
118
# File 'docs/taglib/flac.rb', line 117

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



57
58
# File 'docs/taglib/flac.rb', line 57

def tag
end

#xiph_commentTagLib::Ogg::XiphComment

Returns the Xiph comment tag.

Returns:

Since:

  • 0.5.0



63
64
# File 'docs/taglib/flac.rb', line 63

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



123
124
# File 'docs/taglib/flac.rb', line 123

def xiph_comment?
end