liuxiaolong
2019-05-06 2418a2d61feea858e9e63aa52fd64ddfe17e392a
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
<!DOCTYPE html>
<html>
<head>
    <title>Media Player PNaCl</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta name="author" content="videoexpertsgroup" />
    <meta name="copyright" lang="ru" content="videoexpertsgroup" />
    <meta name="description" content="Demo VXG Media Player for Chrome" />
    <meta name="keywords" content=""/>
    <!-- vxgplayer -->
    <script type="text/javascript" src="vxgplayer-1.8.31.min.js"></script>
    <link href="vxgplayer-1.8.31.min.css" rel="stylesheet"/>
 
    <!-- demo page -->
    <link href="https://www.videoexpertsgroup.com/nacl_player_api/demo.min.css" rel="stylesheet"/>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link href="https://www.videoexpertsgroup.com/nacl_player_api/zenburn.min.css" rel="stylesheet">
    <script src="https://www.videoexpertsgroup.com/nacl_player_api/highlight.min.js"></script>
    <script>
        hljs.initHighlightingOnLoad();
        var indexPlayer = 1;
        function createPlayer(){
            indexPlayer++;
            var playerId = 'vxg_media_player' + indexPlayer;
            var div = document.createElement('div');
            div.setAttribute("id", playerId);
            div.setAttribute("class", "vxgplayer");
            var runtimePlayers = document.getElementById('runtimePlayers');
            runtimePlayers.appendChild(div);
            vxgplayer(playerId, {
                url: '',
                nmf_path: 'media_player.nmf',
                nmf_src: 'pnacl/Release/media_player.nmf',
                latency: 300000,
                aspect_ratio_mode: 1,
                autohide: 3,
                controls: true,
                avsync: true,
                autoreconnect: 1
            }).ready(function(){
                console.log(' =>ready player '+playerId);
                vxgplayer(playerId).src(document.getElementById('url_input').value);
                vxgplayer(playerId).play();
                console.log(' <=ready player '+playerId);
            });
        }
        function removeLatestPlayer(){
            if(indexPlayer > 1){
                var playerId = 'vxg_media_player' + indexPlayer;
                vxgplayer(playerId).dispose();
                document.getElementById('vxg_media_player' + indexPlayer).remove();
                indexPlayer--;
            }
        }
        
        function customDigitalZoomOn(){
            vxgplayer('vxg_media_player1').custom_digital_zoom(true);
            digzoom_on.style.display = "none";
            digzoom_off.style.display = "";
            digzoom_params.style.display = "";
            
        }
        function customDigitalZoomOff(){
            vxgplayer('vxg_media_player1').custom_digital_zoom(false);
            digzoom_on.style.display = "";
            digzoom_off.style.display = "none";
            digzoom_params.style.display = "none";
        }
            
        function setCustomDigitalZoom(){
            try{
                vxgplayer('vxg_media_player1').setCustomDigitalZoom(parseInt(digzoom_ratio.value,10), parseInt(digzoom_x.value,10), parseInt(digzoom_y.value,10))
            }catch(e){
                alert(e);
            }
        }
        
        function resetCustomDigitalZoom(){
            vxgplayer('vxg_media_player1').setCustomDigitalZoom(100, 0, 0);
        }
        
    </script>
</head>
<body>
    
        <div class="menu-fixed">
            <div class="menu">
                <div class="menu-left">
                    <a href="?">VXG Media Player (1.8.31)</a>
                </div>
                <div class="menu-right">
                    <a class="menu-item-right" href="#demo">Demo</a>
                    <a class="menu-item-right" href="#examples">Examples</a>
                    <a class="menu-item-right" href="#support">Support</a>
                    <a class="menu-item-right" href="#download">Download</a>
                    <a class="menu-item-right" href="#jsapi">API</a>
                </div>
            </div>
        </div>
        <div class="content-absolute">
            <div class="content">
                <a class="link-top" name="demo">.</a>
                <h1>Demo</h1>
                Some functions for test (Only for first player):
                <ul>
                    <li>
                        URL:
                        <input id="url_input" type="text" size="60" value="rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov">
                        <button onclick="vxgplayer('vxg_media_player1').src(document.getElementById('url_input').value);">Set</button>
                    </li>
                    <li>
                        Max latency(ms):
                        <input id="url_latency" type="number" size="5" value="300000">
                        <button onclick="vxgplayer('vxg_media_player1').latency(document.getElementById('url_latency').value);">Set</button>
                    </li>
                    <li>
                        Aspect Ratio:
                        <button onclick="vxgplayer('vxg_media_player1').aspectRatioMode(1);">Fit-to-Screen</button>
                        <button onclick="vxgplayer('vxg_media_player1').aspectRatioMode(2);">Crop</button>
                        <button onclick="vxgplayer('vxg_media_player1').aspectRatio(false);">Disable</button>
                    </li>
                    <li>
                        Attribute display:
                        <button onclick="document.getElementById('vxg_media_player1').style.display='none';">None</button>
                        <button onclick="document.getElementById('vxg_media_player1').style.display='inline-block';">Inline-block</button>
                    </li>
                    <li>
                        Attribute visibility:
                        <button onclick="document.getElementById('vxg_media_player1').style.visibility='hidden';">Hidden</button>
                        <button onclick="document.getElementById('vxg_media_player1').style.visibility='';">Empty</button>
                    </li>
                    <li>
                        Autoreconnect: 
                        <button onclick="vxgplayer('vxg_media_player1').autoreconnect(1);">On</button>
                        <button onclick="vxgplayer('vxg_media_player1').autoreconnect(0);">Off</button>
                    </li>
                    <li>Run-Time creation players: 
                        <button onclick="createPlayer();">create new</button>
                        <button onclick="removeLatestPlayer();">remove latest</button>
                    </li>
                    <li>Change Digital Zoom (Ratio, X, Y):
                        <button id="digzoom_on" onclick="customDigitalZoomOn()">On</button>
                        <button id="digzoom_off" onclick="customDigitalZoomOff()" style="display: none;">Off</button>
                        <div id="digzoom_params" style="display: none;">
                            Ratio[100..500] = <input type="text" id="digzoom_ratio" size=3 value="300">
                            X = <input type="text" id="digzoom_x" size=5 value="426">
                            Y = <input type="text" id="digzoom_y" size=5 value="320">
                            <button onclick="setCustomDigitalZoom()">Set</button>
                            <button onclick="resetCustomDigitalZoom()">Reset</button>
                        <div>
                    </li>
                </ul>
 
                <div id="runtimePlayers">
                <div id="vxg_media_player1" class="vxgplayer" url="rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov" aspect-ratio latency="3000000" autostart controls avsync></div>
                </div>
 
                <a class="link-top" name="examples">.</a>
                <h1>Examples</h1>
                <ul>
                    <li><a href="iframeexample.html" target="_blank">Player in iframe example</a></li>
                    <li><a href="multiplayersexample.html" target="_blank">Multiplayers example</a></li>
                    <li><a href="angular2example-1.8.31.zip" target="_blank">Angular 2 Example</a></li>
                </ul>
                
                <a class="link-top" name="support">.</a>
                <h1>Support</h1>
                <a href="http://www.videoexpertsgroup.com/chrome-media-player-plug-in/" target="_blank">Visit the Video Experts Group' Media Player Plug-in page for support</a>
 
                <a class="link-top" name="download">.</a>
                <h1>Download</h1>
                <a href="vxgplayer-1.8.31.zip" target="_blank">vxgplayer-1.8.31.zip</a>
                <p>Please note that you have to place the unzipped package on a Web Server. For testing it locally on your PC you have to run a Web Server on your local PC.
                    We recommend to use a single binary Web Server like <a target="_blank" href="https://www.cesanta.com/products#binary">Mongoose</a> for testing.
                    Just copy the Web Server binary into the unzipped package folder and run it.</p>
                <a class="link-top" name="jsapi">.</a>
                <h1>API</h1>
                <h2>HTML</h2>
 
<h3>Include css + js</h3>
 
<pre><code>&lt;head&gt;
...
    &lt;script type="text/javascript" src="vxgplayer-1.8.31.min.js"&gt;&lt;/script&gt;
    &lt;link href="vxgplayer-1.8.31.min.css" rel="stylesheet"/&gt; 
...
&lt;/head&gt;
</code></pre>
 
<h3>Div element for player</h3>
 
<pre><code>&lt;div class="vxgplayer"
    id="vxg_media_player1" 
    width="640"
    height="480"
    url="rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
    nmf-src="pnacl/Release/media_player.nmf"
    nmf-path="media_player.nmf"
    useragent-prefix="MMP/3.0"
    latency="10000"
    autohide="2"
    volume="0.7"
    avsync
    controls
    mute
    aspect-ratio
    aspect-ratio-mode="1"
    auto-reconnect
    connection-timeout="5000"
    connection-udp="0"
    custom-digital-zoom&gt;&lt;/div&gt;
</code></pre>
 
<h4>Attributes:</h4>
 
<ul>
<li><strong>id</strong> - unique id of player</li>
<li><strong>class</strong> must be 'vxgplayer' - for automatically init all players after load body</li>
<li><strong>width</strong> - width of player, integer </li>
<li><strong>height</strong> - height of player, integer</li>
<li><strong>url</strong> - link to rtsp video</li>
<li><strong>nmf-src</strong> - link to plugin, default value: 'pnacl/Release/media_player.nmf'</li>
<li><strong>nmf-path</strong> - link to plugin, default value: 'media_player.nmf'</li>
<li><strong>latency</strong> - latency, integer</li>
<li><strong>autohide</strong> - autohide panel of the controls after, seconds</li>
<li><strong>volume</strong> - volume, float, Possible values: 0..1</li>
<li><strong>avsync</strong> - If attribute exists then avsync true. If attribute does not exist then avsync false</li>
<li><strong>controls</strong> - Panel with controls. If attribute exists then show controls. If attribute does not exist then hide controls</li>
<li><strong>debug</strong> - Debug mode. If attribute exists then you will see a lot of messages in js console. If attribute does not exist, it will be silent</li>
<li><strong>mute</strong> - Mute audio. If attribute exists then mute. If attribute does not exist then no mute</li>
<li><strong>useragent-prefix</strong> - Set prefix for user agency</li>
<li><strong>aspect-ratio</strong> - If attributes aspect-ratio or aspect-ratio-mode exist then aspectRatio true</li>
<li><strong>aspect-ratio-mode</strong> - 1:Fit-to-Screen(default); 2:Crop; 0:Off. If attribute exists then aspectRatio true</li>
<li><strong>auto-reconnect</strong> - If attribute auto-reconnect exists then the player will be auto reconnected on any error</li>
<li><strong>connection-timeout</strong> - set connection timeout value in milliseconds</li>
<li><strong>connection-udp</strong> - allow UDP connection (by default is off), 0:Off, 1:On</li>
<li><strong>custom-digital-zoom</strong> - if this option exists then digital zoom in control disabled and it is allowing method "setCustomDigitalZoom"</li>
</ul>
 
<h2>JavaScript Examples</h2>
 
<h3>Dynamically create players with options</h3>
 
<p>Put element to your page:</p>
 
<pre><code>&lt;div id="dynamicallyPlayers"&gt;&lt;/div&gt;
</code></pre>
 
<p>And below function will create the players inside element 'dynamicallyPlayers'</p>
 
<pre><code>function createPlayer(){
    indexPlayer++;
    var playerId = 'vxg_media_player' + indexPlayer;
    var div = document.createElement('div');
    div.setAttribute("id", playerId);
    div.setAttribute("class", "vxgplayer");
    var runtimePlayers = document.getElementById('dynamicallyPlayers');
    runtimePlayers.appendChild(div);
    vxgplayer(playerId, {
            url: '',
            nmf_path: 'media_player.nmf',
            nmf_src: 'pnacl/Release/media_player.nmf',
            latency: 300000,
            aspect_ratio_mode: 1,
            autohide: 3,
            controls: true,
            connection_timeout: 5000,
            connection_udp: 0,
            custom_digital_zoom: false
    }).ready(function(){
        console.log(' =&gt;ready player '+playerId);
        vxgplayer(playerId).src('rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov');
        vxgplayer(playerId).play();
        console.log(' &lt;=ready player '+playerId);
    });
 
}
</code></pre>
 
<h3>Init player and/or find player</h3>
 
<pre><code>var player = vxgplayer('vxg_media_player1');
// where 'vxg_media_player1' - unique id element in document
</code></pre>
 
<h3>Play / isPlaying</h3>
 
<pre><code>vxgplayer('vxg_media_player1').play(); // play
vxgplayer('vxg_media_player1').isPlaying() // get play true of false
// or 
var player = vxgplayer('vxg_media_player1');
player.play()
player.isPlaying() // get play true of false
</code></pre>
 
<h3>Pause</h3>
 
<pre><code>vxgplayer('vxg_media_player1').pause();
// or
var player = vxgplayer('vxg_media_player1');
player.pause()
</code></pre>
 
<h3>Stop</h3>
 
<pre><code>vxgplayer('vxg_media_player1').stop();
// or
var player = vxgplayer('vxg_media_player1');
player.stop()
</code></pre>
 
<h3>Autohide</h3>
 
<p>An autohide value of zero means the component should never be set invisible.</p>
 
<pre><code>vxgplayer('vxg_media_player1').autohide(2); // set 2 seconds
vxgplayer('vxg_media_player1').autohide(); // get autohide value
// or
var player = vxgplayer('vxg_media_player1');
player.autohide(2); // set 2 seconds
player.autohide(); // get autohide value
</code></pre>
 
<h3>Aspect Ratio</h3>
 
<pre><code>vxgplayer('vxg_media_player1').aspectRatio(true); // set aspect ration to true
vxgplayer('vxg_media_player1').aspectRatio(); // get aspect ration value
// or
var player = vxgplayer('vxg_media_player1');
player.aspectRatioMode(2); // set aspect ration to true. Mode: Crop
player.aspectRatioMode(); // get aspect ratio mode value
</code></pre>
 
<h3>Auto reconnect</h3>
 
<pre><code>vxgplayer('vxg_media_player1').autoreconnect(1); // set auto-reconnect on
vxgplayer('vxg_media_player1').autoreconnect(); // get autoreconnect value
</code></pre>
 
<h3>Volume</h3>
 
<p>Possible value of volume: 0..1</p>
 
<pre><code>// possible value of volume: from 0 to 1
// example
vxgplayer('vxg_media_player1').volume(0.8); // set volume
var vol = vxgplayer('vxg_media_player1').volume(); // get volume
// or
var player = vxgplayer('vxg_media_player1');
player.volume(0.8); // set volume
var vol = player.volume(); // get volume
</code></pre>
 
<h3>Size</h3>
 
<p>Set new size of player</p>
 
<pre><code>vxgplayer('vxg_media_player1').size(1280, 720); // set size
var size = vxgplayer('vxg_media_player1').size(); // get size
console.log('Player width: ' + size.width);
console.log('Player height: ' + size.height);
// or
var player = vxgplayer('vxg_media_player1');
player.size(1280, 720); // set size
var size2 = player.size(); // get size
console.log('Player width: ' + size2.width);
console.log('Player height: ' + size2.height);
</code></pre>
 
<h3>Latency</h3>
 
<pre><code>vxgplayer('vxg_media_player1').latency(10000); // set latency
console.log(vxgplayer('vxg_media_player1').latency()); // get latency
// or
var player = vxgplayer('vxg_media_player1');
player.latency(10000); // set latency
var ltnc = player.latency(); // get latency
</code></pre>
 
<h3>Connection Timeout (ms)</h3>
 
<pre><code>vxgplayer('vxg_media_player1').connection_timeout(5000); // set connection_timeout 5 seconds
console.log(vxgplayer('vxg_media_player1').connection_timeout()); // get connection_timeout
</code></pre>
 
<h3>Allow UDP connection</h3>
 
<pre><code>vxgplayer('vxg_media_player1').connection_udp(1); // allow UDP connection
vxgplayer('vxg_media_player1').connection_udp(0); // deny UDP connection
</code></pre>
 
<h3>Custom Digital Zoom</h3>
 
<pre><code>vxgplayer('vxg_media_player1').custom_digital_zoom(); // will be return true or false
vxgplayer('vxg_media_player1').custom_digital_zoom(true); // enable custom digital zoom
vxgplayer('vxg_media_player1').custom_digital_zoom(false); // disable custom digital zoom
 
If you change value custom_digital_zoom then player will be reset zoom.
</code></pre>
 
<h3>Change Custom Digital Zoom</h3>
 
<p>This method will available only if <code>custom_digital_zoom()</code> is true</p>
 
<pre><code>vxgplayer('vxg_media_player1').custom_digital_zoom(true); // enable custom digital zoom
 
var ratio = 100; // 100..500
var x = 0; // position in pixels
var y = 0; // position in pixels
vxgplayer('vxg_media_player1').setCustomDigitalZoom(ratio, x, y); // set new custom digital zoom
</code></pre>
 
<h3>Source / URL</h3>
 
<pre><code>vxgplayer('vxg_media_player1').src('rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov'); // set src
var src = vxgplayer('vxg_media_player1').src(); // get src
// or
var player = vxgplayer('vxg_media_player1');
player.src('rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov'); // set src
var src = player.src(); // get src
</code></pre>
 
<h3>Error</h3>
 
<p>This method returned last error code or -1 if has not error.</p>
 
<pre><code>// NO_ERROR == -1
// MEDIA_ERR_URL == 0
// MEDIA_ERR_NETWORK == 1
// MEDIA_ERR_SOURCE == 2
// MEDIA_ERR_CARRIER == 3
// MEDIA_ERR_AUDIO == 4
// MEDIA_ERR_VIDEO == 5
// MEDIA_ERR_AUTHENTICATION == 6
// MEDIA_ERR_BANDWIDTH == 7
// MEDIA_ERR_EOF == 8
 
var err;
 
err = vxgplayer('vxg_media_player1').error(); // get error code
// or
var player = vxgplayer('vxg_media_player1');
var err = player.error(); // get error code
 
// example of handling by code error
switch (err) {
    case 0:
        // MEDIA_ERR_URL
        break
    case 1:
        // MEDIA_ERR_NETWORK
        break
    case 2:
        // MEDIA_ERR_SOURCE
        break
    case 3:
        // MEDIA_ERR_CARRIER
        break
    case 4:
        // MEDIA_ERR_AUDIO
        break
    case 5:
        // MEDIA_ERR_VIDEO
        break
    case 6:
        // MEDIA_ERR_AUTHENTICATION
        break
    case 7:
        // MEDIA_ERR_BANDWIDTH
        break
    case 8:
        // MEDIA_ERR_EOF
        break
    default:
        // no error
}
</code></pre>
 
<h3>Show/Hide Custom Error</h3>
 
<pre><code>vxgplayer('vxg_media_player1').showerror('some error'); // show error overlay
vxgplayer('vxg_media_player1').hideerror(); // hide error overlay
// or
var player = vxgplayer('vxg_media_player1');
player.showerror('some error'); // show error overlay
player.hideerror(); // hide error overlay
</code></pre>
 
<h3>Controls</h3>
 
<pre><code>var ctrls;
 
vxgplayer('vxg_media_player1').controls(true); // set controls to true
ctrls = vxgplayer('vxg_media_player1').controls(); // get controls (return boolean value)
// or
var player = vxgplayer('vxg_media_player1');
player.controls(true); // set controls to true
ctrls = player.controls(); // get controls (return boolean value)
</code></pre>
 
<h3>Debug</h3>
 
<pre><code>var dbg;
 
vxgplayer('vxg_media_player1').debug(true); // set debug mode
dbg = vxgplayer('vxg_media_player1').debug(); // get debug mode
// or
var player = vxgplayer('vxg_media_player1');
player.debug(true); // set debug mode
dbg = player.debug(); // get debug mode
</code></pre>
 
<h3>Mute / isMute</h3>
 
<p>Toggle method. And Getter</p>
 
<pre><code>var mute;
 
vxgplayer('vxg_media_player1').mute(); // toggle mute false -&gt; true and true -&gt; false
mute = vxgplayer('vxg_media_player1').isMute(); // getter
// or
var player = vxgplayer('vxg_media_player1');
player.mute();  // toggle mute false -&gt; true and true -&gt; false
mute = player.isMute(); // get state of mute
</code></pre>
 
<h3>Ready State</h3>
 
<pre><code>// possible values of readyState:
// 0 - PLAYER_STOPPED
// 1 - PLAYER_CONNECTING
// 2 - PLAYER_PLAYING
// 3 - PLAYER_STOPPING
 
var rs;
 
rs = vxgplayer('vxg_media_player1').readyState(); 
// or
var player = vxgplayer('vxg_media_player1');
rs = player.readyState();
// example of handling by code error
switch (rs) {
    case 0:
        // PLAYER_STOPPED
        break
    case 1:
        // PLAYER_CONNECTING
        break
    case 2:
        // PLAYER_PLAYING
        break
    case 3:
        // PLAYER_STOPPING
        break
    default:
        // no ready
}
</code></pre>
 
<h3>Version</h3>
 
<pre><code>var player = vxgplayer('listener2');
player.versionPLG(); //version of chrome plugin
player.versionAPP(); //version of VXG Media Player app
</code></pre>
 
<h3>Callback onReadyStateChange</h3>
 
<pre><code>vxgplayer('vxg_media_player1').onReadyStateChange(function(onreadyState){
    console.log("player LOADED: versionPLG=" + vxgplayer('vxg_media_player1').versionPLG()+" versionAPP="+vxgplayer('vxg_media_player1').versionAPP());
});
// or
var player = vxgplayer('listener2');
player.onReadyStateChange(function(state){
    console.log("player LOADED: versionPLG=" + player.versionPLG()+" versionAPP="+player.versionAPP());
});
</code></pre>
 
<h3>Callback onStateChange</h3>
 
<pre><code>vxgplayer('vxg_media_player1').onStateChange(function(readyState){
    console.log("NEW READY STATE: " + readyState);
});
// or
var player = vxgplayer('listener2');
player.onStateChange(function(state){
    console.log("NEW READY STATE: " + readyState);
});
</code></pre>
 
<h3>Callback onError</h3>
 
<pre><code>vxgplayer('vxg_media_player1').onError(function(player){
    console.log(player.error());
});
// or
var player = vxgplayer('vxg_media_player1');
player.onError(function(player){
    console.log(player.error());
});
</code></pre>
 
<h3>Callback onBandwidthError</h3>
 
<pre><code>// Behaviour:
// 1. If exists handler onBandwidthError then call it.
// 2. If not exists then show error('Problem with bandwidth')
 
vxgplayer('vxg_media_player1').onBandwidthError(function(player){
    console.log(player.error());
});
// or
var player = vxgplayer('vxg_media_player1');
player.onBandwidthError(function(player){
    console.log(player.error());
});
</code></pre>
            </div>
        </div>
 
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            console.log('===player.src='+vxgplayer('vxg_media_player1').src());
            console.log('===player.volume()='+vxgplayer('vxg_media_player1').volume());
            console.log('===player.autohide()='+vxgplayer('vxg_media_player1').autohide());
            console.log('===player.isMute()='+vxgplayer('vxg_media_player1').isMute());
            console.log('===player.isPlaying()='+vxgplayer('vxg_media_player1').isPlaying());
            console.log('===player.autoreconnect()='+vxgplayer('vxg_media_player1').autoreconnect());
            vxgplayer('vxg_media_player1').onReadyStateChange(function(onreadyState){
                console.log("player LOADED: versionPLG=" + vxgplayer('vxg_media_player1').versionPLG()+" versionAPP="+vxgplayer('vxg_media_player1').versionAPP());
            vxgplayer('vxg_media_player1').play();
            });
            vxgplayer('vxg_media_player1').onError(function(onErr){
                console.log("player ERROR: " + vxgplayer('vxg_media_player1').error() + " decoder:"+vxgplayer('vxg_media_player1').errorDecoder());
            });
        })
    </script>
</body>
</html>