control

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 9 Imported by: 6

Documentation

Index

Constants

View Source
const (
	NoStatus      = -1
	StatusPlaying = 0
	StatusPaused  = 1
	StatusStopped = 2
	StatusOther   = 3
)

Play Status

View Source
const (
	ModeListLoop   = 0
	ModeSingleLoop = 1
	ModeRandom     = 2
	ModeSingleStop = 3
)

Play Modes

View Source
const (
	SourceFile = 0
	SourceWeb  = 1
)

Play Source Type

Variables

This section is empty.

Functions

func Release

func Release()

Release 释放所有播放资源,不能再播放除非重新加载。

Types

type Music

type Music struct {
	ID             int
	Name           string
	Author         string
	Album          string
	Cover          string
	Length         int
	FilePath       string
	Handle         uint
	PlaySourceType int
}

Music 歌曲

func (*Music) GetLength

func (m *Music) GetLength() int

GetLength 获取歌曲长度(秒)

func (*Music) GetPosition

func (m *Music) GetPosition() int

GetPosition 获取播放位置(秒)

func (*Music) SetCover

func (m *Music) SetCover(src string)

SetCover 设置歌曲封面

func (*Music) SetPosition

func (m *Music) SetPosition(sec int) int

SetPosition 设置播放位置(秒)

type Player

type Player struct {
	Status            uint
	PlayFeature       int
	PlayMode          int
	LastSecond        int
	CurrentLength     int
	Playlist          []Music
	NowPlayingIndex   int
	LastIndex         int
	NowPlayingSheetID int
	LastHandle        uint
	Login             *account.Login
	LyricSwitch       bool
	Volume            uint
	IsShowProgress    bool
}

Player 音乐播放器

func NewPlayer

func NewPlayer(login *account.Login) *Player

NewPlayer 创建新播放器

func (*Player) AttachFile

func (p *Player) AttachFile(file string)

AttachFile 添加一个文件到播放器的播放列表

func (*Player) AttachFileWeb

func (p *Player) AttachFileWeb(url string)

AttachFileWeb 添加一个网络文件到播放器播放列表

func (*Player) EmptyPlayList

func (p *Player) EmptyPlayList()

EmptyPlayList 清空播放列表

func (*Player) FreeStream

func (p *Player) FreeStream(handle uint) uint32

FreeStream 释放handle占用的资源

func (*Player) GetCurrentIndex

func (p *Player) GetCurrentIndex() int

GetCurrentIndex 获取播放列表当前播放序号

func (*Player) GetLastIndex

func (p *Player) GetLastIndex() int

GetLastIndex 获取下一首应该是那个序号

func (*Player) GetNextIndex

func (p *Player) GetNextIndex() int

GetNextIndex 获取下一首应该是那个序号

func (*Player) GetRandomIndex

func (p *Player) GetRandomIndex() int

GetRandomIndex 获取随机的播放序号,用于随机模式。

func (*Player) GetVolume

func (p *Player) GetVolume() uint

GetVolume 获取音量(0-100)%

func (*Player) Last

func (p *Player) Last()

Last 上一首,如果是随机模式则为上一次播放的歌曲

func (*Player) Next

func (p *Player) Next()

Next 下一首

func (*Player) Pause

func (p *Player) Pause()

Pause 暂停播放

func (*Player) Play

func (p *Player) Play()

Play 播放音乐

func (*Player) RefreshPlayURL

func (p *Player) RefreshPlayURL()

RefreshPlayURL 刷新歌曲的URL,建议每次播放前执行一次,防止链接实效。

func (*Player) RemoveFile

func (p *Player) RemoveFile(index int)

RemoveFile 从播放列表中移除制定序号歌曲

func (*Player) SetCurrentIndex

func (p *Player) SetCurrentIndex(index int)

SetCurrentIndex 设置播放列表当前播放序号

func (*Player) SetPlayFeature

func (p *Player) SetPlayFeature(fea int)

SetPlayFeature 设置播放特点 [我喜欢的|FM|日推等]

func (*Player) SetPlayMode

func (p *Player) SetPlayMode(mode int)

SetPlayMode 设置播放模式 [列表循环|单曲循环|随即|单曲结束等]

func (*Player) SetVolume

func (p *Player) SetVolume(value uint) uint

SetVolume 设置音量(0-100)%

func (*Player) Stop

func (p *Player) Stop()

Stop 停止播放

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL