File tree Expand file tree Collapse file tree 2 files changed +45
-4
lines changed Expand file tree Collapse file tree 2 files changed +45
-4
lines changed Original file line number Diff line number Diff line change 1
1
package audiorecord
2
2
3
3
import (
4
- "strings "
4
+ "github.com/goplus/spx/internal/coroutine "
5
5
"syscall/js"
6
6
)
7
7
@@ -15,8 +15,8 @@ func initScript() {
15
15
}
16
16
scriptInited = true
17
17
18
- window = js .Global ().Get ("window" )
19
- document = js .Global ().Get ("document" )
18
+ window : = js .Global ().Get ("window" )
19
+ document : = js .Global ().Get ("document" )
20
20
21
21
// docuemnt is undefined on node.js
22
22
if ! document .Truthy () {
@@ -46,7 +46,8 @@ func Open(gco *coroutine.Coroutines) *Recorder {
46
46
initScript ()
47
47
audioRecorder := js .Global ().Get ("GopAudioRecorder" )
48
48
audioRecorder .Call ("start" , js .FuncOf (func (this js.Value , args []js.Value ) interface {} {
49
- volume = args [0 ].Float ()
49
+ volume := args [0 ].Float ()
50
+ p .volume = volume
50
51
return nil
51
52
}))
52
53
return p
Original file line number Diff line number Diff line change
1
+
2
+ mkdir res/
3
+ GOEXPERIMENT=noregabi GOOS=js GOARCH=wasm go build --tags canvas -o test.wasm
4
+ cp -f " $( go env GOROOT) /misc/wasm/wasm_exec.js" ./
5
+ cp -f " $( go env GOROOT) /misc/wasm/wasm_exec.html" ./
6
+ cp -f -p ../res/* ./res/
7
+
8
+
9
+ echo ' // test.go
10
+ package main
11
+
12
+ import (
13
+ "flag"
14
+ "log"
15
+ "net/http"
16
+ "strings"
17
+ )
18
+
19
+ var (
20
+ listen = flag.String("listen", ":8080", "listen address")
21
+ dir = flag.String("dir", ".", "directory to serve")
22
+ )
23
+
24
+ func main() {
25
+ flag.Parse()
26
+ log.Printf("listening on %q...", *listen)
27
+ log.Fatal(http.ListenAndServe(*listen, http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
28
+ if strings.HasSuffix(req.URL.Path, ".wasm") {
29
+ resp.Header().Set("content-type", "application/wasm")
30
+ }
31
+
32
+ http.FileServer(http.Dir(*dir)).ServeHTTP(resp, req)
33
+ })))
34
+ }' > server.go
35
+ go run server.go
36
+ rm -rf wasm_exec.js
37
+ rm -rf wasm_exec.html
38
+ rm -rf server.go
39
+ rm -rf res/
40
+ rm -rf * .wasm
You can’t perform that action at this time.
0 commit comments