-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBugReportPanel.wo
255 lines (205 loc) · 8.64 KB
/
BugReportPanel.wo
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
Use cWebFloatingPanel.pkg
Use cWebGroup.pkg
Use cWebLabel.pkg
Use cWebCheckbox.pkg
Use cWebButton.pkg
Use cWebHtmlBox.pkg
Use cWebEdit.pkg
Use WinUuid.pkg
Use cMediaStreamAPI.pkg
Use cMediaStreamRecordingAPI.pkg
Object oBugReportPanel is a cWebFloatingPanel
Set piWidth to 400
Set psCssClass to "Shadow"
Set pePosition to fpFloatFixed
Set piTop to 50
Set piRight to 16
// Enable OnHide event
Set pbServerOnHide to True
Set pbNoAccessibilityCheck to True
// Make sure we fit nicely on small screens
WebSetResponsive piLeft rmMobilePortrait to 16
WebSetResponsive piWidth rmMobilePortrait to -1
{ WebProperty=Server }
Property String psFileName ""
{ WebProperty=Server }
Property String psMimeType ""
Object oUserMediaStream is a cUserMediaStreamAPI
Set pbAudio to True
End_Object
Object oDisplayMediaStream is a cDisplayMediaStreamAPI
Set pbSelfBrowserSurface to True
Set pbPreferCurrentTab to True
Set pbMonitorTypeSurfaces to False
End_Object
Object oMediaStreamRecording is a cMediaStreamRecordingAPI
Set pbServerOnConnect to True
Set pbServerOnStart to True
Set pbServerOnDataAvailable to True
Set pbServerOnStop to True
// Always add the display stream - user device (mic) stream added by checkbox below
Send AddStream oDisplayMediaStream
// Auto-start recording when connection is established, in 1 second blocks
Procedure OnConnect String sState tMediaStreamInfo stInfo
Send Start 1000
End_Procedure
Procedure OnStart String sState
String sTempFileName
// Switch to the 'stop' view
WebSet pbRender of oWebGroupStart to False
WebSet pbRender of oWebGroupStop to True
WebSet piWidth of oBugReportPanel to 200
// Keeping it simple - create a file to store the recording in
Make_Temp_File "tmp" sTempFileName
WebSet psFileName of oBugReportPanel to sTempFileName
WebSet psMimeType of oBugReportPanel to "" // We will get the mime type in OnDataAvailable
End_Procedure
Procedure OnDataAvailable String sMimeType UChar[] ucData
String sRememberedMimeType sTempFileName
Send ClientLog (SFormat("Received %1 bytes of %2", SizeOfArray(ucData), sMimeType))
// Remember the mime type
WebGet psMimeType of oBugReportPanel to sRememberedMimeType
If (sRememberedMimeType = "") Begin
WebSet psMimeType of oBugReportPanel to sMimeType
End
// Write data to temp file
WebGet psFileName of oBugReportPanel to sTempFileName
Append_Output ("binary: " + sTempFileName)
Write ucData
Close_Output
End_Procedure
Procedure OnStop String sState
// Switch to the 'confirm' view
WebSet piWidth of oBugReportPanel to 400
WebSet pbRender of oWebGroupStop to False
WebSet pbRender of oWebGroupConfirm to True
// Show recording to user
Send AttachRecording "my-video-element"
End_Procedure
End_Object
Object oWebGroupStart is a cWebGroup
Set piColumnCount to 3
Set pbShowBorder to False
Set pbShowCaption to False
Object oWebLabelStart is a cWebLabel
Set piColumnSpan to 0
Set psCaption to "Found a bug? We are so sorry! We would love it, if you would click 'Start screen recording' below, and show us what happened."
End_Object
Object oWebCheckboxSound is a cWebCheckbox
Set piColumnSpan to 0
Set psCaption to "Include sound from my microphone, so I can explain"
Set pbServerOnChange to True
// Only adding the user device stream to recording if checkbox is checked
Procedure OnChange String sNewValue String sOldValue
Boolean bChecked
Get GetChecked to bChecked
If (bChecked) Begin
Send AddStream of oMediaStreamRecording oUserMediaStream
End
Else Begin
Send RemoveStream of oMediaStreamRecording oUserMediaStream
End
End_Procedure
End_Object
Object oWebButton1 is a cWebButton
Set piColumnSpan to 2
Set psCaption to "Start screen recording"
Procedure OnClick
Send Connect of oMediaStreamRecording
End_Procedure
End_Object
Object oWebButton2 is a cWebButton
Set piColumnIndex to 2
Set piColumnSpan to 1
Set psCaption to "Cancel"
Procedure OnClick
Send Hide of oBugReportPanel
End_Procedure
End_Object
End_Object
Object oWebGroupStop is a cWebGroup
Set pbShowBorder to False
Set pbShowCaption to False
Set pbRender to False
Object oWebButton3 is a cWebButton
Set psCaption to "Stop recording"
Procedure OnClick
// Will also trigger OnStop
Send Disconnect of oMediaStreamRecording
End_Procedure
End_Object
End_Object
Object oWebGroupConfirm is a cWebGroup
Set piColumnCount to 3
Set pbShowBorder to False
Set pbShowCaption to False
Set pbRender to False
Object oVideo is a cWebHtmlBox
Set piColumnSpan to 0
Set psHtml to '<video controls style="width: 100%" id="my-video-element"></video>'
End_Object
Object oWebEdit1 is a cWebEdit
Set piColumnSpan to 0
Set psLabel to "Please provide any relevant details:"
Set peLabelPosition to lpTop
End_Object
Object oWebButton4 is a cWebButton
Set piColumnSpan to 2
Set psCaption to "Submit bug report"
Procedure OnClick
String sMimeType sExtension sFileName
WebGet psMimeType of oBugReportPanel to sMimeType
If (sMimeType matches "video/mp4*") Begin
Move ".mp4" to sExtension
End
Else If (sMimeType matches "video/x-matroska*") Begin
Move ".mkv" to sExtension
End
Else If (sMimeType matches "video/webm*") Begin
Move ".webm" to sExtension
End
Else Begin
Move ".tmp" to sExtension
End
WebGet psFileName of oBugReportPanel to sFileName
RenameFile sFileName to (RandomHexUUID() + sExtension)
WebSet psFileName of oBugReportPanel to ""
//TODO: Store this recording along with any other relevant information
Send Hide of oBugReportPanel
Send ShowInfoBox "Your bug report has been saved, and we will get back to you ASAP!" "Thank you"
End_Procedure
End_Object
Object oWebButton5 is a cWebButton
Set piColumnIndex to 2
Set piColumnSpan to 1
Set psCaption to "Cancel"
Procedure OnClick
Send Hide of oBugReportPanel
End_Procedure
End_Object
End_Object
Procedure Show
Boolean bIsUserMediaSupported bIsDisplayMediaSupported bIsRecordingSupported
// Reset panel
WebGet pbIsSupported of oUserMediaStream to bIsUserMediaSupported
WebGet pbIsSupported of oDisplayMediaStream to bIsDisplayMediaSupported
WebGet pbIsSupported of oMediaStreamRecording to bIsRecordingSupported
If (not(bIsDisplayMediaSupported and bIsRecordingSupported)) Begin
Send ShowInfoBox "Sorry, screen recording is not supported on this device."
Procedure_Return
End
WebSet pbRender of (oWebCheckboxSound(oWebGroupStart(Self))) to bIsUserMediaSupported
WebSet pbRender of oWebGroupStart to True
WebSet pbRender of oWebGroupStop to False
WebSet pbRender of oWebGroupConfirm to False
Forward Send Show
End_Procedure
Procedure OnHide
String sTempFileName
Forward Send OnHide
WebGet psFileName to sTempFileName
If (sTempFileName <> "") Begin
EraseFile sTempFileName
End
End_Procedure
End_Object