mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-07 02:42:50 +08:00
* rewrite * update submodule * make width height configurable * update dependency * update * update file * update dep * fix basic config layout * update plugin management * more stuff * add blacklist * fix todo * fix windows gethandle * update windows update guide * update windows build guide * include go mod tidy in script * update todo * fix source session * fix text output * add plugin play duration control * fix id diange not working * update todo * update version number
40 lines
849 B
Go
40 lines
849 B
Go
package plugins
|
|
|
|
import (
|
|
"AynaLivePlayer/core/model"
|
|
"AynaLivePlayer/global"
|
|
"AynaLivePlayer/pkg/logger"
|
|
)
|
|
|
|
var plugins []model.Plugin = make([]model.Plugin, 0)
|
|
var log logger.ILogger
|
|
|
|
func Initialize() {
|
|
plugins = make([]model.Plugin, 0)
|
|
log = global.Logger.WithPrefix("Plugin")
|
|
}
|
|
|
|
func LoadPlugin(plugin model.Plugin) {
|
|
log.Info("[Plugin] Loading plugin: " + plugin.Name())
|
|
if err := plugin.Enable(); err != nil {
|
|
log.Warnf("[Plugin] Failed to load plugin: %s, %s", plugin.Name(), err)
|
|
return
|
|
}
|
|
plugins = append(plugins, plugin)
|
|
}
|
|
|
|
func LoadPlugins(plugins ...model.Plugin) {
|
|
for _, plugin := range plugins {
|
|
LoadPlugin(plugin)
|
|
}
|
|
}
|
|
|
|
func ClosePlugins() {
|
|
for _, plugin := range plugins {
|
|
if err := plugin.Disable(); err != nil {
|
|
log.Warnf("[Plugin] Failed to close plugin: %s, %s", plugin.Name(), err)
|
|
continue
|
|
}
|
|
}
|
|
}
|