Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
30bb40a7
Commit
30bb40a7
authored
Aug 26, 2018
by
LoveEevee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pausing in bufferedloop
parent
881c4037
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
src/js/bufferedloop.js
src/js/bufferedloop.js
+21
-13
No files found.
src/js/bufferedloop.js
View file @
30bb40a7
...
...
@@ -5,8 +5,8 @@ class BufferedLoop{
this
.
context
=
new
AudioContext
()
this
.
buffers
=
[]
this
.
sources
=
new
Set
()
this
.
loadCallback
=
[]
this
.
bufferedTime
=
0
this
.
iteration
=
0
this
.
bgm1
=
bgm1
this
.
bgm2
=
bgm2
this
.
loadSound
(
bgm1
.
url
,
0
)
...
...
@@ -28,11 +28,13 @@ class BufferedLoop{
setLoaded
(){
if
(
this
.
buffers
[
0
]
&&
this
.
buffers
[
1
]){
this
.
loaded
=
true
if
(
this
.
loadCallback
){
this
.
loadCallback
()
delete
this
.
loadCallback
for
(
var
i
in
this
.
loadCallback
){
this
.
loadCallback
[
i
]
()
}
}
}
onLoad
(
callback
){
this
.
loadCallback
.
push
(
callback
)
}
playSound
(
buffer
,
time
,
duration
){
var
self
=
this
...
...
@@ -41,11 +43,14 @@ class BufferedLoop{
source
.
connect
(
this
.
context
.
destination
)
source
.
start
(
time
)
this
.
bufferedTime
=
time
+
duration
this
.
sources
.
add
(
source
)
setTimeout
(
function
(){
self
.
sources
.
delete
(
source
)
var
sourceObject
=
{
source
:
source
,
timeout
:
setTimeout
(
function
(){
self
.
sources
.
delete
(
sourceObject
)
},
duration
*
1000
)
}
this
.
sources
.
add
(
sourceObject
)
}
addLoop
(){
if
(
this
.
context
.
currentTime
>
this
.
bufferedTime
-
1
){
this
.
playSound
(
...
...
@@ -59,10 +64,12 @@ class BufferedLoop{
play
(){
var
self
=
this
if
(
!
this
.
loaded
){
this
.
loadCallback
=
this
.
play
return
return
this
.
onLoad
(
function
(){
self
.
play
()
})
}
this
.
start
=
this
.
context
.
currentTime
+
0.1
this
.
iteration
=
0
this
.
playSound
(
this
.
buffers
[
0
],
this
.
start
,
...
...
@@ -75,8 +82,9 @@ class BufferedLoop{
}
pause
(){
clearInterval
(
this
.
interval
)
this
.
sources
.
forEach
(
function
(
source
){
source
.
stop
(
0
)
this
.
sources
.
forEach
(
function
(
sourceObject
){
sourceObject
.
source
.
stop
(
0
)
clearTimeout
(
sourceObject
.
timeout
)
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment