当前位置: 首页>>代码示例>>Golang>>正文


Golang Metadata.Picture方法代码示例

本文整理汇总了Golang中github.com/dhowden/tag.Metadata.Picture方法的典型用法代码示例。如果您正苦于以下问题:Golang Metadata.Picture方法的具体用法?Golang Metadata.Picture怎么用?Golang Metadata.Picture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/dhowden/tag.Metadata的用法示例。


在下文中一共展示了Metadata.Picture方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: dataURL

func dataURL(m tag.Metadata) string {
	p := m.Picture()
	if p == nil {
		return ""
	}
	if p.MIMEType == "-->" {
		return string(p.Data)
	}
	return fmt.Sprintf("data:%s;base64,%s", p.MIMEType, base64.StdEncoding.EncodeToString(p.Data))
}
开发者ID:shazow,项目名称:mog,代码行数:10,代码来源:codec.go

示例2: printMetadata

func printMetadata(m tag.Metadata) {
	fmt.Printf("Metadata Format: %v\n", m.Format())
	fmt.Printf("File Type: %v\n", m.FileType())

	fmt.Printf(" Title: %v\n", m.Title())
	fmt.Printf(" Album: %v\n", m.Album())
	fmt.Printf(" Artist: %v\n", m.Artist())
	fmt.Printf(" Composer: %v\n", m.Composer())
	fmt.Printf(" Genre: %v\n", m.Genre())
	fmt.Printf(" Year: %v\n", m.Year())

	track, trackCount := m.Track()
	fmt.Printf(" Track: %v of %v\n", track, trackCount)

	disc, discCount := m.Disc()
	fmt.Printf(" Disc: %v of %v\n", disc, discCount)

	fmt.Printf(" Picture: %v\n", m.Picture())
	fmt.Printf(" Lyrics: %v\n", m.Lyrics())
}
开发者ID:herotl2005,项目名称:tag,代码行数:20,代码来源:tag.go

示例3: Open

// Open the given file and return an http.File which contains the artwork, and hence
// the Name() of the returned file will have an extention for the artwork, not the
// media file.
func (afs artworkFileSystem) Open(ctx context.Context, path string) (http.File, error) {
	f, err := afs.FileSystem.Open(ctx, path)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	stat, err := f.Stat()
	if err != nil {
		return nil, err
	}

	var m tag.Metadata
	m, err = tag.ReadFrom(f)
	if err != nil {
		return nil, fmt.Errorf("error extracting picture from '%v': %v", path, err)
	}

	p := m.Picture()
	if p == nil {
		return nil, fmt.Errorf("no picture attached to '%v'", path)
	}

	name := stat.Name()
	if p.Ext != "" {
		name += "." + p.Ext
	}

	return &file{
		ReadSeeker: bytes.NewReader(p.Data),
		stat: &fileInfo{
			name:    name,
			size:    int64(len(p.Data)),
			modTime: stat.ModTime(),
		},
	}, nil
}
开发者ID:davelondon,项目名称:tchaik,代码行数:40,代码来源:artwork.go


注:本文中的github.com/dhowden/tag.Metadata.Picture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。