-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtab_capture.go
51 lines (41 loc) · 1.6 KB
/
tab_capture.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package chrome
import "github.com/gopherjs/gopherjs/js"
type TabCapture struct {
o *js.Object
}
/*
* Types
*/
type CaptureInfo struct {
*js.Object
TabId int `js:"tabId"`
Status string `js:"status"`
FullScreen bool `js:"fullScreen"`
}
type MediaStreamConstraint struct {
Mandatory *js.Object `js:"mandatory"`
Optional *js.Object `js:"optional"`
}
/*
* Methods
*/
// Capture captures the visible area of the currently active tab. Capture can only be started on
// the currently active tab after the extension has been invoked. Capture is maintained across page
// navigations within the tab, and stops when the tab is closed, or the media stream is closed by the extension.
func (t *TabCapture) Capture(options Object, callback func(stream interface{})) {
t.o.Call("capture", options, callback)
}
// GetCapturedTabs returns a list of tabs that have requested capture or are being captured, i.e. status
// != stopped and status != error. This allows extensions to inform the user that there is an existing tab
// capture that would prevent a new tab capture from succeeding (or to prevent redundant requests for the same tab).
func (t *TabCapture) GetCapturedTabs(callback func(result []CaptureInfo)) {
t.o.Call("getCapturedTabs", callback)
}
/*
* Events
*/
// OnStatusChanged event fired when the capture status of a tab changes. This allows extension authors to keep track
// of the capture status of tabs to keep UI elements like page actions and infobars in sync.
func (t *TabCapture) OnStatusChanged(callback func(info CaptureInfo)) {
t.o.Get("onStatusChanged").Call("addListener", callback)
}