fixed newplayer func

This commit is contained in:
2025-03-25 14:55:03 -04:00
parent 85e64a7037
commit 53c6bce3dd
4 changed files with 6 additions and 10 deletions
+2 -6
View File
@@ -27,11 +27,11 @@ const (
Stopped Stopped
) )
func NewPlayer() *Player { func NewPlayer() (*Player, error) {
return &Player{ return &Player{
// TODO: variable speaker sample rates // TODO: variable speaker sample rates
sampleRate: beep.SampleRate(44100), sampleRate: beep.SampleRate(44100),
} }, nil
} }
func (p *Player) Init(ctx context.Context) { func (p *Player) Init(ctx context.Context) {
@@ -51,10 +51,6 @@ func (p *Player) Play(filePath string) error {
return fmt.Errorf("failed to open file %w", err) return fmt.Errorf("failed to open file %w", err)
} }
if p.streamer == nil || p.format == nil {
}
streamer, format, err := mp3.Decode(f) streamer, format, err := mp3.Decode(f)
if err != nil { if err != nil {
return fmt.Errorf("failed to decode mp3 %w", err) return fmt.Errorf("failed to decode mp3 %w", err)
+1 -1
View File
@@ -1 +1 @@
5fbf12469d224a93954efecb5886e8a6 6cdae3f6b1951ca1bf1d6febf086be53
+1 -1
View File
@@ -7,4 +7,4 @@ export function ChangeState(arg1:player.PlayerState):Promise<void>;
export function Init(arg1:context.Context):Promise<void>; export function Init(arg1:context.Context):Promise<void>;
export function Play():Promise<void>; export function Play(arg1:string):Promise<void>;
+2 -2
View File
@@ -10,6 +10,6 @@ export function Init(arg1) {
return window['go']['player']['Player']['Init'](arg1); return window['go']['player']['Player']['Init'](arg1);
} }
export function Play() { export function Play(arg1) {
return window['go']['player']['Player']['Play'](); return window['go']['player']['Player']['Play'](arg1);
} }