This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
925 lines (768 loc) · 44.2 KB
/
index.html
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="http://normanzb.github.io/playcorder-core-as3/favicon.ico?v=2" />
<link rel="icon" sizes="16x16 32x32" href="./favicon.ico?v=2">
<title>Playcorder.core.as3</title>
<script type="text/javascript">
/* SWFObject v2.2 <http://code.google.com/p/swfobject/>
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
</script>
<style type="text/css">
body
{
background-color: #1abc9c;
font-size: 12px;
color: #FFF;
text-shadow: 1px 1px 0 rgba(0,0,0, .8);
}
.separator
{
height:0;
width: 0;
overflow: hidden;
}
.separator.horizontal
{
width: 100%;
border-top: 1px dashed green;
border-bottom: 1px dashed transparent;
}
.panel button,
.panel input[type=button]
{
border-radius: 0;
border: 0px solid #FFF;
background-color: #FFF;
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
appearance: none;
}
.panel button[disabled],
.panel input[type=button][disabled]
{
background-color: #DEDEDE;
}
.stretcher
{
box-sizing: border-box;
display: inline-block;
}
.stretcher.w100p
{
margin: 1% 2%;
width: 96%;
}
.stretcher.w50p
{
margin: 1% 2%;
width: 46%;
}
.stretcher.w33p
{
margin: 1% 2%;
width: 29%;
}
.topbar
{
overflow: hidden;
margin: 20px 0;
}
.topbar .logo
{
float: left;
padding: 10px;
background: #FFF;
width: 60px;
height: 60px;
}
.topbar .comp-name
{
position: relative;
float: left;
height: 80px;
margin: 0;
padding: 0 10px;
font-size: 40px;
line-height: 80px;
}
.topbar .sub-title
{
position: absolute;
left: 10px;
top: 10px;
font-size: 12px;
line-height: 12px;
}
.panel
{
margin: 20px 0;
}
.panel table
{
width: 100%;
border-spacing: 0;
border-collapse: collapse;
text-align: center;
}
#view-hex
{
width: 100%;
font-family: Courier;
}
.caption
{
display: inline-block;
background-color: #000;
color: #FFF;
margin: 10px 0;
padding: 0 5px;
}
.label
{
background-color: #EFEFEF;
padding: 0 5px;
color: #000;
text-shadow: none;
}
.status
{
width: 60px;
padding: 0 10px;
display: inline-block;
}
.playcorder
{
position: fixed;
top: 50%;
left: 50%;
width: 215px;
height: 140px;
}
.playcorder > .inner
{
position: relative;
top: -70px;
left: -50%;
-webkit-box-shadow: 0 0 2300px 700px rgba(0,0,0,0.5);
box-shadow: 0 0 2300px 700px rgba(0,0,0,0.5);
}
.playcorder:after
{
position: absolute;
top: -5px;
left: -30px;
content: 'Loading...';
}
.playcorder.loaded:after
{
display: none;
}
.playcorder.ready
{
top: -9999px;
left: -9999px;
}
/* spinner */
.spinner
{
position: fixed;
right: 35px;
top: 70px;
z-index: 1;
}
.spinner {
margin: 20px auto;
width: 50px;
height: 30px;
text-align: center;
font-size: 10px;
}
.spinner > div {
background-color: #FFF;
height: 100%;
width: 6px;
display: inline-block;
-webkit-animation: stretchdelay 1.2s infinite ease-in-out;
animation: stretchdelay 1.2s infinite ease-in-out;
}
.spinner .rect2 {
-webkit-animation-delay: -1.1s;
animation-delay: -1.1s;
}
.spinner .rect3 {
-webkit-animation-delay: -1.0s;
animation-delay: -1.0s;
}
.spinner .rect4 {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s;
}
.spinner .rect5 {
-webkit-animation-delay: -0.8s;
animation-delay: -0.8s;
}
@-webkit-keyframes stretchdelay {
0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
20% { -webkit-transform: scaleY(1.0) }
}
@keyframes stretchdelay {
0%, 40%, 100% {
transform: scaleY(0.4);
-webkit-transform: scaleY(0.4);
} 20% {
transform: scaleY(1.0);
-webkit-transform: scaleY(1.0);
}
}
</style>
</head>
<body>
<div id="spinner" class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
<div class='topbar'>
<div class="logo"><img src="./icon.png" /></div>
<h1 class="comp-name">
<span>Playcorder.Core.AS3</span>
<div class="sub-title">Flash based recording component with intuitive Javascript APIs</div>
</h1>
</div>
<div class="playcorder">
<div class="inner">
<div id="playcorder-placeholder"></div>
</div>
</div>
<div class="separator horizontal"></div>
<div id="panel" class="panel">
<table>
<tr>
<td width="10%"><button id="mic-start" disabled="disabled">loading</button></td>
<td width="5%">-></td>
<td width="10%"><button id="mic-stop" disabled="disabled">stopped</button></td>
<td width="5%">-></td>
<td width="45%">
<button
id="mic-download-raw" class="stretcher w33p" disabled="disabled">download as raw data (js)
</button><span
class="stretcher w33p" style="text-align:center;">->
</span><button
id="mic-encode-wave" class="stretcher w33p" disabled="disabled">encode to wave (js)</button> <br />
<button id="mic-download-wave" class="stretcher w100p" disabled="disabled">download as wave (as)</button><br />
<button id="mic-download-mp3" class="stretcher w100p" disabled="disabled">download as mp3 (as)</button><br />
<button id="mic-upload-wave" class="stretcher w100p" disabled="disabled">upload to ./test as wave file using plain post (as)</button> <br />
<button id="mic-upload-mp3" class="stretcher w50p" disabled="disabled">upload to ./test as mp3 file using multipart(as)
</button><button
id="mic-upload-mp3-confirm" class="stretcher w50p" disabled="disabled">click to confirm upload</button>
</td>
<td width="5%">-></td>
<td width="20%">
<button id="mic-buffer-play" class="stretcher w50p" disabled="disabled">Play shared buffer (js)</button><br />
<button id="mic-buffer-play-as" class="stretcher w50p" disabled="disabled">Play recorded audio (as)</button><br />
<button id="mic-buffer-extract" class="stretcher w50p" disabled="disabled">Extract as file (js)</button><br />
<button id="mic-buffer-hexview" class="stretcher w50p" disabled="disabled">Display Hex (js)</button>
</td>
</tr>
</table>
</div>
<span class="caption">Info:</span>
<div id="view-info">
<span class="label">muted:</span><span id="mic-muted" class="status muted"></span>
<span class="label">volume:</span><span id="mic-volume" class="status volume"></span>
<span class="label">recorded duration:</span><span id="mic-duration" class="status duration"></span>
</div>
<span class="caption">Shared Buffer Hex View:</span>
<div id="view-hex"></div>
<script type="text/javascript">
forceDownload = function(blob, filename){
var url = (window.URL || window.webkitURL).createObjectURL(blob);
var link = window.document.createElement('a');
link.href = url;
link.download = filename || 'file';
var click = document.createEvent("Event");
click.initEvent("click", true, true);
link.dispatchEvent(click);
}
function floatTo16BitPCM(output, offset, input){
for (var i = 0; i < input.length; i++, offset+=2){
var s = Math.max(-1, Math.min(1, input[i]));
output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true);
}
}
function writeString(view, offset, string){
for (var i = 0; i < string.length; i++){
view.setUint8(offset + i, string.charCodeAt(i));
}
}
function encodeWAV(config){
var CHUNK_ID = 'RIFF';
var TYPE = 'WAVE';
var FORMAT_CHUNK_ID = 'fmt ';
var DATA_CHUNK_ID = 'data' ;
var BIT_LEN = 16;
var BYTE_PER_SAMPLE = ( BIT_LEN / 8 );
var cur = 0;
var view = new DataView(new ArrayBuffer(44 + config.samples.length * 2));
/* RIFF identifier */
writeString(view, cur, CHUNK_ID);
cur+= CHUNK_ID.length;
/* file length */
view.setUint32(cur, 36 + config.samples.length * BYTE_PER_SAMPLE, true);
cur += 4;
/* RIFF type */
writeString(view, cur, TYPE);
cur += TYPE.length;
/* format chunk identifier */
writeString(view, cur, FORMAT_CHUNK_ID);
cur += FORMAT_CHUNK_ID.length;
/* format chunk length */
view.setUint32(cur, 16, true);
cur += 4;
/* sample format (raw) */
view.setUint16(cur, 1, true);
cur += 2;
/* channel count */
view.setUint16(cur, config.channels.length, true);
cur += 2;
/* sample rate */
view.setUint32(cur, config.rate, true);
cur += 4;
/* byte rate (sample rate * block align) */
view.setUint32(cur, config.rate * BYTE_PER_SAMPLE * config.channels.length, true);
cur += 4;
/* block align (channel count * bytes per sample) */
view.setUint16(cur, config.channels.length * BYTE_PER_SAMPLE, true);
cur += 2;
/* bits per sample */
view.setUint16(cur, BIT_LEN, true);
cur += 2;
/* data chunk identifier */
writeString(view, cur, DATA_CHUNK_ID);
cur += DATA_CHUNK_ID.length;
/* data chunk length */
view.setUint32( cur, config.samples.length * BYTE_PER_SAMPLE, true);
cur += 4;
floatTo16BitPCM(view, cur, config.samples);
return view;
}
(function(){
// embed swf by using swfobject
var ID_SWF = 'playcorder';
var params = {};
params.quality = "high";
params.wmode = "transparent";
params.allowscriptaccess = "always";
params.allowfullscreen = "false";
swfobject.embedSWF(
"./dist/Playcorder.swf",
"playcorder-placeholder",
"215", "140",
"11.9.0", "playerProductInstall.swf",
{}, params, {
id: ID_SWF,
name: ID_SWF
},
function( result ){
window.pc = result.ref;
var elSpinner = document.getElementById('spinner');
var elPlaycorder = document.getElementsByClassName('playcorder')[0];
function showSpinner()
{
elSpinner.style.display = 'block';
}
function hideSpinner()
{
elSpinner.style.display = 'none';
}
pc.onloaded = function() {
elPlaycorder.className += " loaded";
hideSpinner();
};
pc.onready = function(){
var curGUID;
var elMuted = document.getElementById('mic-muted');
var elVolume = document.getElementById('mic-volume');
var elDuration = document.getElementById('mic-duration');
var btnStart = document.getElementById('mic-start');
var btnStop = document.getElementById('mic-stop');
var btnDownloadRaw = document.getElementById('mic-download-raw');
var btnEncodeWave = document.getElementById('mic-encode-wave');
var btnDownloadWave = document.getElementById('mic-download-wave');
var btnDownloadMP3 = document.getElementById('mic-download-mp3');
var btnPlayBuffer = document.getElementById('mic-buffer-play');
var btnPlayBufferAs = document.getElementById('mic-buffer-play-as');
var btnShowHex = document.getElementById('mic-buffer-hexview');
var btnUploadWave = document.getElementById('mic-upload-wave');
var btnUploadMP3 = document.getElementById('mic-upload-mp3');
var btnUploadMP3Confirm = document.getElementById('mic-upload-mp3-confirm');
var btnDownloadAsFile = document.getElementById('mic-buffer-extract');
var elViewHex = document.getElementById('view-hex');
var sharedArrayBuffer;
var sharedDownloadObject;
var sharedAudioContext;
btnStart.removeAttribute('disabled');
btnStart.innerHTML = 'start';
elPlaycorder.className += " ready";
// init rtmp recorder
// pc.recorder.initialize({
// gain:50,
// rate:44,
// silence:0,
// quality: 9,
// type:'asrrtmp',
// server: 'rtmpt://speechtest.englishtown.com:1935/asrstreaming',
// params: {
// connection:[{
// type: 'macro',
// value: 'server'
// }, {
// type: 'macro',
// value: 'guid'
// },
// // context
// "<?xml version='1.0'?><TPContext version='1.1'><Sentences><Sentence AVG='87.555490868151' DEV='18.831834969547' id='1' display_trans='pig' trans='LTIKN '><Word id='1' trans='LTIKN' display_trans='PIG' weight='1'/></Sentence></Sentences><NewWords><NewWord id='1' trans='LTIKN' prons='P IH G'/></NewWords><Dictionary><![CDATA[LTIKN P IH G]]></Dictionary></TPContext>",
// // student id
// 0,
// // activity id
// 0
// ]
// }
// });
pc.recorder.initialize({
gain: 50,
rate: 44,
silence: 0,
quality: 9,
type: 'local'
});
// detect recorder changes
pc.recorder.onchange = function(){
if ( pc.recorder_muted() ) {
elMuted.innerHTML = 'yes';
}
else {
elMuted.innerHTML = 'no';
}
};
pc.recorder.onerror = function(){
};
pc.recorder.onstarted = function(evt) {
if ( evt.guid != curGUID)
{
return;
}
btnStart.innerHTML = 'started'
btnStart.setAttribute('disabled', 'disabled');
btnStop.innerHTML = 'stop';
btnStop.removeAttribute('disabled', 'disabled');
window.startTime = new Date() * 1;
showSpinner();
};
pc.recorder.onstopped = function(evt) {
window.recordingTime = window.startTime - new Date() * 1;
if ( evt.guid != curGUID)
{
return;
}
btnStart.innerHTML = 'start'
btnStart.removeAttribute('disabled');
btnStop.innerHTML = 'stopped';
btnStop.setAttribute('disabled', 'disabled');
btnDownloadRaw.removeAttribute('disabled');
btnDownloadWave.removeAttribute('disabled');
btnDownloadMP3.removeAttribute('disabled');
btnUploadWave.removeAttribute('disabled');
btnUploadMP3.removeAttribute('disabled');
btnPlayBufferAs.removeAttribute('disabled');
elDuration.innerHTML = pc.recorder.result.duration();
hideSpinner();
};
btnStart.onclick = function() {
// use session guid to make sure the event is fired for current session
curGUID = pc.recorder.start();
console.log( curGUID )
};
btnStop.onclick = function() {
pc.recorder.stop();
};
btnDownloadRaw.onclick = function() {
var downloadGuid;
pc.recorder.result.ondownloaded = function(obj){
if ( downloadGuid != obj.guid ){
return;
}
console.log('audio data length: ' + obj.length);
hideSpinner();
// try to convert it to arraybuffer
if ( !window.ArrayBuffer ){
alert('Data is downloaded, However your browser does not support essential APIs for Javascript audio processing, try flash APIs!');
return;
}
var ab = new ArrayBuffer( obj.data.length );
var ui8a = new Uint8Array(ab);
for( var i = 0; i < obj.data.length; i++ )
{
ui8a[ i ] = obj.data[i];
}
sharedArrayBuffer= ab;
sharedDownloadObject = obj;
btnEncodeWave.removeAttribute("disabled");
btnDownloadAsFile.removeAttribute('disabled');
btnShowHex.removeAttribute('disabled');
};
pc.recorder.result.ondownloadfailed = function(obj)
{
if ( downloadGuid != obj.guid ){
return;
}
console.log('downloading failed: ' + obj.message);
hideSpinner();
};
// try to download data
downloadGuid = pc.recorder.result.download( );
showSpinner();
};
btnEncodeWave.onclick = function(){
// get samples
var dv = new DataView( sharedArrayBuffer );
var samples = [];
var obj = sharedDownloadObject;
var cur = 0;
while( cur < dv.byteLength )
{
samples.push(dv.getFloat32(cur));
cur+=4;
}
console.log('sample length: ', samples.length)
// convert to wave
var wavView = encodeWAV({
rate: obj.rate == 44 ? 44100 : 0,
channels: obj.channels,
samples: samples
});
sharedArrayBuffer = wavView.buffer;
console.log('wav done', wavView);
// display it
var ui8a = new Uint8Array( wavView.buffer );
var arr = [];
for(var i = 0; i < ui8a.length;i++){
arr.push(ui8a[i]);
}
btnPlayBuffer.removeAttribute('disabled');
btnShowHex.removeAttribute('disabled');
btnDownloadAsFile.removeAttribute('disabled');
};
btnDownloadMP3.onclick = function() {
var downloadGuid;
pc.recorder.result.ondownloaded = function(obj){
if ( downloadGuid != obj.guid ){
return;
}
console.log('mp3 length: ' + obj.length);
console.log('done:' + new Date() * 1);
hideSpinner();
// try to convert it to arraybuffer
if ( !window.ArrayBuffer ){
alert('Data is downloaded, However your browser does not support essential APIs for Javascript audio processing, try flash APIs!');
return;
}
var ab = new ArrayBuffer( obj.data.length );
var ui8a = new Uint8Array(ab);
for( var i = 0; i < obj.data.length; i++ )
{
ui8a[ i ] = obj.data[i];
}
sharedArrayBuffer = ab;
sharedDownloadObject = obj;
btnPlayBuffer.removeAttribute('disabled');
btnDownloadAsFile.removeAttribute('disabled');
btnShowHex.removeAttribute('disabled');
};
pc.recorder.result.ondownloadfailed = function(obj)
{
if ( downloadGuid != obj.guid ){
return;
}
console.log('downloading failed: ' + obj.message);
hideSpinner();
};
// try to download data
console.log('start:' + new Date() * 1);
downloadGuid = pc.recorder.result.download( 'mp3' );
showSpinner();
};
btnShowHex.onclick = function(){
var ui8a = new Uint8Array( sharedArrayBuffer );
var arr = [];
for(var i = 0; i < ui8a.length;i++){
arr.push(ui8a[i]);
}
elViewHex.innerHTML = arr.map(function(el){
var ret = el.toString(16);
if (ret.length == 1) {
ret = "0"+ret;
}
return ret;
}).join(' ');
};
btnDownloadWave.onclick = function() {
var downloadGuid;
pc.recorder.result.ondownloaded = function(obj){
if ( downloadGuid != obj.guid ){
return;
}
console.log('wave length: ' + obj.length);
console.log('done:' + new Date() * 1);
hideSpinner();
// try to convert it to arraybuffer
if ( !window.ArrayBuffer ){
alert('Data is downloaded, However your browser does not support essential APIs for Javascript audio processing, try flash APIs!');
return;
}
var ab = new ArrayBuffer( obj.data.length );
var ui8a = new Uint8Array(ab);
for( var i = 0; i < obj.data.length; i++ )
{
ui8a[ i ] = obj.data[i];
}
sharedArrayBuffer = ab;
sharedDownloadObject = obj;
btnPlayBuffer.removeAttribute('disabled');
btnDownloadAsFile.removeAttribute('disabled');
btnShowHex.removeAttribute('disabled');
};
pc.recorder.result.ondownloadfailed = function(obj)
{
if ( downloadGuid != obj.guid ){
return;
}
console.log('downloading failed: ' + obj.message);
hideSpinner();
};
// try to download data
console.log('start:' + new Date() * 1);
downloadGuid = pc.recorder.result.download( 'wave' );
showSpinner();
};
btnPlayBuffer.onclick = function(){
// try to play the audio by using web audio api
var AudioContext = webkitAudioContext || mozAudioContext;
if ( !AudioContext )
{
alert('Your browser does not support essential APIs for Javascript audio processing, try flash APIs!');
return;
}
var audioContext = sharedAudioContext || new AudioContext();
sharedAudioContext = audioContext ;
console.log('audio api instantiated');
try{
var audioBuffer = audioContext.createBuffer(
sharedArrayBuffer, sharedDownloadObject.channels.length == 1
// obj.channels.length, obj.length, obj.rate
);
}
catch(ex){
console.log(ex)
}
console.log('audio buffer created', audioBuffer);
var source = audioContext.createBufferSource();
console.log('source created');
source.connect(audioContext.destination);
console.log('destination connected');
source.buffer = audioBuffer;
console.log('buffer assigned')
source.start(0);
console.log('started')
};
btnPlayBufferAs.onclick = function() {
pc.player.initialize({});
pc.player.onstarted = function(evt){
console.log('play started ' + evt.guid);
};
pc.player.onstopped = function(evt){
console.log('play stopped ' + evt.guid);
};
var guid = pc.player.start();
console.log('play guid: ' + guid);
};
btnUploadWave.onclick = function(){
var uploadGuid;
uploadGuid = pc.recorder.result.upload('wave', './test');
pc.recorder.result.onuploaded = function(obj)
{
if (uploadGuid != obj.guid){
return;
}
alert('uploaded');
hideSpinner();
};
pc.recorder.result.onuploadfailed = function(obj)
{
if (uploadGuid != obj.guid){
return;
}
alert(obj.message);
hideSpinner();
};
console.log('upload guid:', uploadGuid);
showSpinner();
};
btnUploadMP3.onclick = function(){
var uploadGuid;
uploadGuid = pc.recorder.result.upload('mp3', './test', { format:'multipart', params: {test: "foobar"}});
pc.recorder.result.onuploadinteraction = function(){
btnUploadMP3Confirm.removeAttribute('disabled');
btnUploadMP3Confirm.onclick = function(){
pc.recorder.result.interact();
};
};
pc.recorder.result.onuploaded = function(obj)
{
if (uploadGuid != obj.guid){
return;
}
alert('uploaded');
hideSpinner();
};
pc.recorder.result.onuploadfailed = function(obj)
{
if (uploadGuid != obj.guid){
return;
}
alert(obj.message);
hideSpinner();
};
console.log('upload guid:', uploadGuid);
showSpinner();
};
btnDownloadAsFile.onclick = function() {
var dv = new DataView(sharedArrayBuffer);
var type = 'audio/wav';
var filename = 'file.wav';
if ( dv.getUint8(0) == 255 ) {
type = 'audio/mp3';
filename = 'file.mp3';
}
forceDownload( new Blob([ dv ], { type: type} ), filename );
};
// update the recorder volume
;(function looper(){
elVolume.innerHTML = pc.recorder.activity();
setTimeout( looper, 30 );
})();
};
}
);
})();
</script>
<a href="https://github.com/normanzb/playcorder-core-as3"><img style="position: absolute; top: 0; right: 30px; border: 0;" src="https://github.com/jamesflorentino/fork-ribbons/raw/master/ribbons/orange-black.png" alt="Fork me on GitHub"></a>
</body>
</html>