mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-10 12:18:13 +08:00
maybe fix panic when close the software
This commit is contained in:
@@ -13,9 +13,6 @@ func setupPlayerWindow() {
|
|||||||
playerWindow.SetCloseIntercept(func() {
|
playerWindow.SetCloseIntercept(func() {
|
||||||
playerWindow.Hide()
|
playerWindow.Hide()
|
||||||
})
|
})
|
||||||
MainWindow.SetOnClosed(func() {
|
|
||||||
playerWindow.Close()
|
|
||||||
})
|
|
||||||
playerWindow.Hide()
|
playerWindow.Hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/aynakeya/go-mpv"
|
"github.com/aynakeya/go-mpv"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
"math"
|
"math"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var running bool = false
|
var running bool = false
|
||||||
@@ -60,7 +61,8 @@ func SetupPlayer() {
|
|||||||
}
|
}
|
||||||
if e.EventId == mpv.EVENT_SHUTDOWN {
|
if e.EventId == mpv.EVENT_SHUTDOWN {
|
||||||
log.Info("[MPV Player] libmpv shutdown")
|
log.Info("[MPV Player] libmpv shutdown")
|
||||||
StopPlayer()
|
// should not call, otherwise StopPlayer gonna be call twice and cause panic
|
||||||
|
// StopPlayer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -68,11 +70,31 @@ func SetupPlayer() {
|
|||||||
|
|
||||||
func StopPlayer() {
|
func StopPlayer() {
|
||||||
cfg.AudioDevice = libmpv.GetPropertyString("audio-device")
|
cfg.AudioDevice = libmpv.GetPropertyString("audio-device")
|
||||||
|
log.Debugf("successfully get audio-device and set config %s", cfg.AudioDevice)
|
||||||
log.Info("stopping mpv player")
|
log.Info("stopping mpv player")
|
||||||
running = false
|
running = false
|
||||||
// stop player async, should be closed in the end anyway
|
done := make(chan struct{})
|
||||||
go libmpv.TerminateDestroy()
|
|
||||||
log.Info("mpv player stopped")
|
// Stop player async but wait for at most 1 second
|
||||||
|
go func() {
|
||||||
|
//err := libmpv.SetOptionString("vo", "no")
|
||||||
|
//if err != nil {
|
||||||
|
// log.Error("fail to reseting window handle to 0")
|
||||||
|
//}
|
||||||
|
// todo: when call TerminateDestroy after wid has been set, a c code panic will arise.
|
||||||
|
// maybe because the window mpv attach to has been closed. so handle was closed twice
|
||||||
|
// for now. just don't destroy it. because it also might fix configuration
|
||||||
|
// not properly saved issue
|
||||||
|
libmpv.TerminateDestroy()
|
||||||
|
close(done)
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
log.Info("mpv player stopped")
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
log.Error("mpv player stop timed out")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var prevPercentPos float64 = 0
|
var prevPercentPos float64 = 0
|
||||||
|
|||||||
2
todo.txt
2
todo.txt
@@ -18,6 +18,8 @@
|
|||||||
----
|
----
|
||||||
|
|
||||||
Finished
|
Finished
|
||||||
|
- 2024.08.25 : 添加是否播放闲置歌单选项
|
||||||
|
- 2024.08.14 : 网页输出模版上线
|
||||||
- 2024.08.06 : 修复使用身份码连接的时候房管无法切歌的问题
|
- 2024.08.06 : 修复使用身份码连接的时候房管无法切歌的问题
|
||||||
- 2024.07.25 : 或许修复配置无法正确保存的问题
|
- 2024.07.25 : 或许修复配置无法正确保存的问题
|
||||||
- 2024.07.20 : fyne升级,字体修改为自动加载系统字体, 设置中可设置mpv是否现实歌曲封面
|
- 2024.07.20 : fyne升级,字体修改为自动加载系统字体, 设置中可设置mpv是否现实歌曲封面
|
||||||
|
|||||||
Reference in New Issue
Block a user