mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
doc: Ogg/Vorbis is now available on Safari (#294)
This commit is contained in:
parent
fec530ebbc
commit
7b4af1b12d
@ -13,7 +13,7 @@ A simple SNES-like 2D game library in Go
|
|||||||
* [Android](https://github.com/hajimehoshi/ebiten/wiki/Android)
|
* [Android](https://github.com/hajimehoshi/ebiten/wiki/Android)
|
||||||
* [iOS](https://github.com/hajimehoshi/ebiten/wiki/iOS)
|
* [iOS](https://github.com/hajimehoshi/ebiten/wiki/iOS)
|
||||||
|
|
||||||
Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.
|
Note: Gamepads is not available on Safari/Android/iOS. Keyboard is not available on Android/iOS.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<dt>Web browsers</dt>
|
<dt>Web browsers</dt>
|
||||||
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome, Firefox and Safari on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
|
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome, Firefox and Safari on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p><small>Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.</small></p>
|
<p><small>Note: Gamepads is not available on Safari/Android/iOS. Keyboard is not available on Android/iOS.</small></p>
|
||||||
|
|
||||||
<h2 id="features">Features</h2>
|
<h2 id="features">Features</h2>
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
|
@ -51,8 +51,6 @@ func (s *Stream) Size() int64 {
|
|||||||
// Decode decodes Ogg/Vorbis data to playable stream.
|
// Decode decodes Ogg/Vorbis data to playable stream.
|
||||||
//
|
//
|
||||||
// The sample rate must be same as that of audio context.
|
// The sample rate must be same as that of audio context.
|
||||||
//
|
|
||||||
// This function returns error on Safari.
|
|
||||||
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
||||||
decoded, channelNum, sampleRate, err := decode(src)
|
decoded, channelNum, sampleRate, err := decode(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -75,6 +75,7 @@ func init() {
|
|||||||
type Player struct {
|
type Player struct {
|
||||||
audioPlayer *audio.Player
|
audioPlayer *audio.Player
|
||||||
total time.Duration
|
total time.Duration
|
||||||
|
seekedCh chan error
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -156,6 +157,9 @@ func (p *Player) updateBar() error {
|
|||||||
if p.audioPlayer == nil {
|
if p.audioPlayer == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if p.seekedCh != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if !ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) {
|
if !ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) {
|
||||||
mouseButtonState[ebiten.MouseButtonLeft] = 0
|
mouseButtonState[ebiten.MouseButtonLeft] = 0
|
||||||
return nil
|
return nil
|
||||||
@ -174,7 +178,12 @@ func (p *Player) updateBar() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
pos := time.Duration(x-bx) * p.total / time.Duration(bw)
|
pos := time.Duration(x-bx) * p.total / time.Duration(bw)
|
||||||
return p.audioPlayer.Seek(pos)
|
p.seekedCh = make(chan error, 1)
|
||||||
|
go func() {
|
||||||
|
// This can't be done parallely! !?!?
|
||||||
|
p.seekedCh <- p.audioPlayer.Seek(pos)
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) close() error {
|
func (p *Player) close() error {
|
||||||
@ -242,6 +251,17 @@ Press Z or X to change volume of the music
|
|||||||
%s`, ebiten.CurrentFPS(), currentTimeStr)
|
%s`, ebiten.CurrentFPS(), currentTimeStr)
|
||||||
if musicPlayer == nil {
|
if musicPlayer == nil {
|
||||||
msg += "\nNow Loading..."
|
msg += "\nNow Loading..."
|
||||||
|
} else if musicPlayer.seekedCh != nil {
|
||||||
|
select {
|
||||||
|
case err := <-musicPlayer.seekedCh:
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
close(musicPlayer.seekedCh)
|
||||||
|
musicPlayer.seekedCh = nil
|
||||||
|
default:
|
||||||
|
msg += "\nSeeking..."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := ebitenutil.DebugPrint(screen, msg); err != nil {
|
if err := ebitenutil.DebugPrint(screen, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<dt>Web browsers</dt>
|
<dt>Web browsers</dt>
|
||||||
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome, Firefox and Safari on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
|
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome, Firefox and Safari on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p><small>Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.</small></p>
|
<p><small>Note: Gamepads is not available on Safari/Android/iOS. Keyboard is not available on Android/iOS.</small></p>
|
||||||
|
|
||||||
<h2 id="features">Features</h2>
|
<h2 id="features">Features</h2>
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
|
Loading…
Reference in New Issue
Block a user