Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

640 lines
22 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Media Player PNaCl</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta http-equiv="Pragma" content="no-cache">
  7. <meta http-equiv="Expires" content="-1">
  8. <meta name="author" content="videoexpertsgroup" />
  9. <meta name="copyright" lang="ru" content="videoexpertsgroup" />
  10. <meta name="description" content="Demo VXG Media Player for Chrome" />
  11. <meta name="keywords" content=""/>
  12. <!-- vxgplayer -->
  13. <script type="text/javascript" src="vxgplayer-1.8.23.min.js"></script>
  14. <link href="vxgplayer-1.8.23.min.css" rel="stylesheet"/>
  15. <!-- demo page -->
  16. <link href="https://www.videoexpertsgroup.com/nacl_player_api/demo.min.css" rel="stylesheet"/>
  17. <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
  18. <link href="https://www.videoexpertsgroup.com/nacl_player_api/zenburn.min.css" rel="stylesheet">
  19. <script src="https://www.videoexpertsgroup.com/nacl_player_api/highlight.min.js"></script>
  20. <script>
  21. hljs.initHighlightingOnLoad();
  22. var indexPlayer = 1;
  23. function createPlayer(){
  24. indexPlayer++;
  25. var playerId = 'vxg_media_player' + indexPlayer;
  26. var div = document.createElement('div');
  27. div.setAttribute("id", playerId);
  28. div.setAttribute("class", "vxgplayer");
  29. var runtimePlayers = document.getElementById('runtimePlayers');
  30. runtimePlayers.appendChild(div);
  31. vxgplayer(playerId, {
  32. url: '',
  33. nmf_path: 'media_player.nmf',
  34. nmf_src: 'pnacl/Release/media_player.nmf',
  35. latency: 300000,
  36. aspect_ratio_mode: 1,
  37. autohide: 3,
  38. controls: true,
  39. avsync: true,
  40. autoreconnect: 1
  41. }).ready(function(){
  42. console.log(' =>ready player '+playerId);
  43. vxgplayer(playerId).src(document.getElementById('url_input').value);
  44. vxgplayer(playerId).play();
  45. console.log(' <=ready player '+playerId);
  46. });
  47. }
  48. function removeLatestPlayer(){
  49. if(indexPlayer > 1){
  50. var playerId = 'vxg_media_player' + indexPlayer;
  51. vxgplayer(playerId).dispose();
  52. document.getElementById('vxg_media_player' + indexPlayer).remove();
  53. indexPlayer--;
  54. }
  55. }
  56. function customDigitalZoomOn(){
  57. vxgplayer('vxg_media_player1').custom_digital_zoom(true);
  58. digzoom_on.style.display = "none";
  59. digzoom_off.style.display = "";
  60. digzoom_params.style.display = "";
  61. }
  62. function customDigitalZoomOff(){
  63. vxgplayer('vxg_media_player1').custom_digital_zoom(false);
  64. digzoom_on.style.display = "";
  65. digzoom_off.style.display = "none";
  66. digzoom_params.style.display = "none";
  67. }
  68. function setCustomDigitalZoom(){
  69. try{
  70. vxgplayer('vxg_media_player1').setCustomDigitalZoom(parseInt(digzoom_ratio.value,10), parseInt(digzoom_x.value,10), parseInt(digzoom_y.value,10))
  71. }catch(e){
  72. alert(e);
  73. }
  74. }
  75. function resetCustomDigitalZoom(){
  76. vxgplayer('vxg_media_player1').setCustomDigitalZoom(100, 0, 0);
  77. }
  78. </script>
  79. </head>
  80. <body>
  81. <div class="menu-fixed">
  82. <div class="menu">
  83. <div class="menu-left">
  84. <a href="?">VXG Media Player (1.8.23)</a>
  85. </div>
  86. <div class="menu-right">
  87. <a class="menu-item-right" href="#demo">Demo</a>
  88. <a class="menu-item-right" href="#examples">Examples</a>
  89. <a class="menu-item-right" href="#support">Support</a>
  90. <a class="menu-item-right" href="#download">Download</a>
  91. <a class="menu-item-right" href="#jsapi">API</a>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="content-absolute">
  96. <div class="content">
  97. <a class="link-top" name="demo">.</a>
  98. <h1>Demo</h1>
  99. Some functions for test (Only for first player):
  100. <ul>
  101. <li>
  102. URL:
  103. <input id="url_input" type="text" size="60" value="rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov">
  104. <button onclick="vxgplayer('vxg_media_player1').src(document.getElementById('url_input').value);">Set</button>
  105. </li>
  106. <li>
  107. Max latency(ms):
  108. <input id="url_latency" type="number" size="5" value="300000">
  109. <button onclick="vxgplayer('vxg_media_player1').latency(document.getElementById('url_latency').value);">Set</button>
  110. </li>
  111. <li>
  112. Aspect Ratio:
  113. <button onclick="vxgplayer('vxg_media_player1').aspectRatioMode(1);">Fit-to-Screen</button>
  114. <button onclick="vxgplayer('vxg_media_player1').aspectRatioMode(2);">Crop</button>
  115. <button onclick="vxgplayer('vxg_media_player1').aspectRatio(false);">Disable</button>
  116. </li>
  117. <li>
  118. Attribute display:
  119. <button onclick="document.getElementById('vxg_media_player1').style.display='none';">None</button>
  120. <button onclick="document.getElementById('vxg_media_player1').style.display='inline-block';">Inline-block</button>
  121. </li>
  122. <li>
  123. Attribute visibility:
  124. <button onclick="document.getElementById('vxg_media_player1').style.visibility='hidden';">Hidden</button>
  125. <button onclick="document.getElementById('vxg_media_player1').style.visibility='';">Empty</button>
  126. </li>
  127. <li>
  128. Autoreconnect:
  129. <button onclick="vxgplayer('vxg_media_player1').autoreconnect(1);">On</button>
  130. <button onclick="vxgplayer('vxg_media_player1').autoreconnect(0);">Off</button>
  131. </li>
  132. <li>Run-Time creation players:
  133. <button onclick="createPlayer();">create new</button>
  134. <button onclick="removeLatestPlayer();">remove latest</button>
  135. </li>
  136. <li>Change Digital Zoom (Ratio, X, Y):
  137. <button id="digzoom_on" onclick="customDigitalZoomOn()">On</button>
  138. <button id="digzoom_off" onclick="customDigitalZoomOff()" style="display: none;">Off</button>
  139. <div id="digzoom_params" style="display: none;">
  140. Ratio[100..500] = <input type="text" id="digzoom_ratio" size=3 value="300">
  141. X = <input type="text" id="digzoom_x" size=5 value="426">
  142. Y = <input type="text" id="digzoom_y" size=5 value="320">
  143. <button onclick="setCustomDigitalZoom()">Set</button>
  144. <button onclick="resetCustomDigitalZoom()">Reset</button>
  145. <div>
  146. </li>
  147. </ul>
  148. <div id="runtimePlayers">
  149. <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>
  150. </div>
  151. <a class="link-top" name="examples">.</a>
  152. <h1>Examples</h1>
  153. <ul>
  154. <li><a href="iframeexample.html" target="_blank">Player in iframe example</a></li>
  155. <li><a href="multiplayersexample.html" target="_blank">Multiplayers example</a></li>
  156. </ul>
  157. <a class="link-top" name="support">.</a>
  158. <h1>Support</h1>
  159. <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>
  160. <a class="link-top" name="download">.</a>
  161. <h1>Download</h1>
  162. <a href="vxgplayer-1.8.23.zip" target="_blank">vxgplayer-1.8.23.zip</a>
  163. <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.
  164. We recommend to use a single binary Web Server like <a target="_blank" href="https://www.cesanta.com/products#binary">Mongoose</a> for testing.
  165. Just copy the Web Server binary into the unzipped package folder and run it.</p>
  166. <a class="link-top" name="jsapi">.</a>
  167. <h1>API</h1>
  168. <h2>HTML</h2>
  169. <h3>Include css + js</h3>
  170. <pre><code>&lt;head&gt;
  171. ...
  172. &lt;script type="text/javascript" src="vxgplayer-1.8.23.min.js"&gt;&lt;/script&gt;
  173. &lt;link href="vxgplayer-1.8.23.min.css" rel="stylesheet"/&gt;
  174. ...
  175. &lt;/head&gt;
  176. </code></pre>
  177. <h3>Div element for player</h3>
  178. <pre><code>&lt;div class="vxgplayer"
  179. id="vxg_media_player1"
  180. width="640"
  181. height="480"
  182. url="rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
  183. nmf-src="pnacl/Release/media_player.nmf"
  184. nmf-path="media_player.nmf"
  185. useragent-prefix="MMP/3.0"
  186. latency="10000"
  187. autohide="2"
  188. volume="0.7"
  189. avsync
  190. controls
  191. mute
  192. aspect-ratio
  193. aspect-ratio-mode="1"
  194. auto-reconnect
  195. connection-timeout="5000"
  196. connection-udp="0"
  197. custom-digital-zoom&gt;&lt;/div&gt;
  198. </code></pre>
  199. <h4>Attributes:</h4>
  200. <ul>
  201. <li><strong>id</strong> - unique id of player</li>
  202. <li><strong>class</strong> must be 'vxgplayer' - for automatically init all players after load body</li>
  203. <li><strong>width</strong> - width of player, integer </li>
  204. <li><strong>height</strong> - height of player, integer</li>
  205. <li><strong>url</strong> - link to rtsp video</li>
  206. <li><strong>nmf-src</strong> - link to plugin, default value: 'pnacl/Release/media_player.nmf'</li>
  207. <li><strong>nmf-path</strong> - link to plugin, default value: 'media_player.nmf'</li>
  208. <li><strong>latency</strong> - latency, integer</li>
  209. <li><strong>autohide</strong> - autohide panel of the controls after, seconds</li>
  210. <li><strong>volume</strong> - volume, float, Possible values: 0..1</li>
  211. <li><strong>avsync</strong> - If attribute exists then avsync true. If attribute does not exist then avsync false</li>
  212. <li><strong>controls</strong> - Panel with controls. If attribute exists then show controls. If attribute does not exist then hide controls</li>
  213. <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>
  214. <li><strong>mute</strong> - Mute audio. If attribute exists then mute. If attribute does not exist then no mute</li>
  215. <li><strong>useragent-prefix</strong> - Set prefix for user agency</li>
  216. <li><strong>aspect-ratio</strong> - If attributes aspect-ratio or aspect-ratio-mode exist then aspectRatio true</li>
  217. <li><strong>aspect-ratio-mode</strong> - 1:Fit-to-Screen(default); 2:Crop; 0:Off. If attribute exists then aspectRatio true</li>
  218. <li><strong>auto-reconnect</strong> - If attribute auto-reconnect exists then the player will be auto reconnected on any error</li>
  219. <li><strong>connection-timeout</strong> - set connection timeout value in milliseconds</li>
  220. <li><strong>connection-udp</strong> - allow UDP connection (by default is off), 0:Off, 1:On</li>
  221. <li><strong>custom-digital-zoom</strong> - if this option exists then digital zoom in control disabled and it is allowing method "setCustomDigitalZoom"</li>
  222. </ul>
  223. <h2>JavaScript Examples</h2>
  224. <h3>Dynamically create players with options</h3>
  225. <p>Put element to your page:</p>
  226. <pre><code>&lt;div id="dynamicallyPlayers"&gt;&lt;/div&gt;
  227. </code></pre>
  228. <p>And below function will create the players inside element 'dynamicallyPlayers'</p>
  229. <pre><code>function createPlayer(){
  230. indexPlayer++;
  231. var playerId = 'vxg_media_player' + indexPlayer;
  232. var div = document.createElement('div');
  233. div.setAttribute("id", playerId);
  234. div.setAttribute("class", "vxgplayer");
  235. var runtimePlayers = document.getElementById('dynamicallyPlayers');
  236. runtimePlayers.appendChild(div);
  237. vxgplayer(playerId, {
  238. url: '',
  239. nmf_path: 'media_player.nmf',
  240. nmf_src: 'pnacl/Release/media_player.nmf',
  241. latency: 300000,
  242. aspect_ratio_mode: 1,
  243. autohide: 3,
  244. controls: true,
  245. connection_timeout: 5000,
  246. connection_udp: 0,
  247. custom_digital_zoom: false
  248. }).ready(function(){
  249. console.log(' =&gt;ready player '+playerId);
  250. vxgplayer(playerId).src('rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov');
  251. vxgplayer(playerId).play();
  252. console.log(' &lt;=ready player '+playerId);
  253. });
  254. }
  255. </code></pre>
  256. <h3>Init player and/or find player</h3>
  257. <pre><code>var player = vxgplayer('vxg_media_player1');
  258. // where 'vxg_media_player1' - unique id element in document
  259. </code></pre>
  260. <h3>Play / isPlaying</h3>
  261. <pre><code>vxgplayer('vxg_media_player1').play(); // play
  262. vxgplayer('vxg_media_player1').isPlaying() // get play true of false
  263. // or
  264. var player = vxgplayer('vxg_media_player1');
  265. player.play()
  266. player.isPlaying() // get play true of false
  267. </code></pre>
  268. <h3>Pause</h3>
  269. <pre><code>vxgplayer('vxg_media_player1').pause();
  270. // or
  271. var player = vxgplayer('vxg_media_player1');
  272. player.pause()
  273. </code></pre>
  274. <h3>Stop</h3>
  275. <pre><code>vxgplayer('vxg_media_player1').stop();
  276. // or
  277. var player = vxgplayer('vxg_media_player1');
  278. player.stop()
  279. </code></pre>
  280. <h3>Autohide</h3>
  281. <p>An autohide value of zero means the component should never be set invisible.</p>
  282. <pre><code>vxgplayer('vxg_media_player1').autohide(2); // set 2 seconds
  283. vxgplayer('vxg_media_player1').autohide(); // get autohide value
  284. // or
  285. var player = vxgplayer('vxg_media_player1');
  286. player.autohide(2); // set 2 seconds
  287. player.autohide(); // get autohide value
  288. </code></pre>
  289. <h3>Aspect Ratio</h3>
  290. <pre><code>vxgplayer('vxg_media_player1').aspectRatio(true); // set aspect ration to true
  291. vxgplayer('vxg_media_player1').aspectRatio(); // get aspect ration value
  292. // or
  293. var player = vxgplayer('vxg_media_player1');
  294. player.aspectRatioMode(2); // set aspect ration to true. Mode: Crop
  295. player.aspectRatioMode(); // get aspect ratio mode value
  296. </code></pre>
  297. <h3>Auto reconnect</h3>
  298. <pre><code>vxgplayer('vxg_media_player1').autoreconnect(1); // set auto-reconnect on
  299. vxgplayer('vxg_media_player1').autoreconnect(); // get autoreconnect value
  300. </code></pre>
  301. <h3>Volume</h3>
  302. <p>Possible value of volume: 0..1</p>
  303. <pre><code>// possible value of volume: from 0 to 1
  304. // example
  305. vxgplayer('vxg_media_player1').volume(0.8); // set volume
  306. var vol = vxgplayer('vxg_media_player1').volume(); // get volume
  307. // or
  308. var player = vxgplayer('vxg_media_player1');
  309. player.volume(0.8); // set volume
  310. var vol = player.volume(); // get volume
  311. </code></pre>
  312. <h3>Size</h3>
  313. <p>Set new size of player</p>
  314. <pre><code>vxgplayer('vxg_media_player1').size(1280, 720); // set size
  315. var size = vxgplayer('vxg_media_player1').size(); // get size
  316. console.log('Player width: ' + size.width);
  317. console.log('Player height: ' + size.height);
  318. // or
  319. var player = vxgplayer('vxg_media_player1');
  320. player.size(1280, 720); // set size
  321. var size2 = player.size(); // get size
  322. console.log('Player width: ' + size2.width);
  323. console.log('Player height: ' + size2.height);
  324. </code></pre>
  325. <h3>Latency</h3>
  326. <pre><code>vxgplayer('vxg_media_player1').latency(10000); // set latency
  327. console.log(vxgplayer('vxg_media_player1').latency()); // get latency
  328. // or
  329. var player = vxgplayer('vxg_media_player1');
  330. player.latency(10000); // set latency
  331. var ltnc = player.latency(); // get latency
  332. </code></pre>
  333. <h3>Connection Timeout (ms)</h3>
  334. <pre><code>vxgplayer('vxg_media_player1').connection_timeout(5000); // set connection_timeout 5 seconds
  335. console.log(vxgplayer('vxg_media_player1').connection_timeout()); // get connection_timeout
  336. </code></pre>
  337. <h3>Allow UDP connection</h3>
  338. <pre><code>vxgplayer('vxg_media_player1').connection_udp(1); // allow UDP connection
  339. vxgplayer('vxg_media_player1').connection_udp(0); // deny UDP connection
  340. </code></pre>
  341. <h3>Custom Digital Zoom</h3>
  342. <pre><code>vxgplayer('vxg_media_player1').custom_digital_zoom(); // will be return true or false
  343. vxgplayer('vxg_media_player1').custom_digital_zoom(true); // enable custom digital zoom
  344. vxgplayer('vxg_media_player1').custom_digital_zoom(false); // disable custom digital zoom
  345. If you change value custom_digital_zoom then player will be reset zoom.
  346. </code></pre>
  347. <h3>Change Custom Digital Zoom</h3>
  348. <p>This method will available only if <code>custom_digital_zoom()</code> is true</p>
  349. <pre><code>vxgplayer('vxg_media_player1').custom_digital_zoom(true); // enable custom digital zoom
  350. var ratio = 100; // 100..500
  351. var x = 0; // position in pixels
  352. var y = 0; // position in pixels
  353. vxgplayer('vxg_media_player1').setCustomDigitalZoom(ratio, x, y); // set new custom digital zoom
  354. </code></pre>
  355. <h3>Source / URL</h3>
  356. <pre><code>vxgplayer('vxg_media_player1').src('rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov'); // set src
  357. var src = vxgplayer('vxg_media_player1').src(); // get src
  358. // or
  359. var player = vxgplayer('vxg_media_player1');
  360. player.src('rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov'); // set src
  361. var src = player.src(); // get src
  362. </code></pre>
  363. <h3>Error</h3>
  364. <p>This method returned last error code or -1 if has not error.</p>
  365. <pre><code>// NO_ERROR == -1
  366. // MEDIA_ERR_URL == 0
  367. // MEDIA_ERR_NETWORK == 1
  368. // MEDIA_ERR_SOURCE == 2
  369. // MEDIA_ERR_CARRIER == 3
  370. // MEDIA_ERR_AUDIO == 4
  371. // MEDIA_ERR_VIDEO == 5
  372. // MEDIA_ERR_AUTHENTICATION == 6
  373. // MEDIA_ERR_BANDWIDTH == 7
  374. // MEDIA_ERR_EOF == 8
  375. var err;
  376. err = vxgplayer('vxg_media_player1').error(); // get error code
  377. // or
  378. var player = vxgplayer('vxg_media_player1');
  379. var err = player.error(); // get error code
  380. // example of handling by code error
  381. switch (err) {
  382. case 0:
  383. // MEDIA_ERR_URL
  384. break
  385. case 1:
  386. // MEDIA_ERR_NETWORK
  387. break
  388. case 2:
  389. // MEDIA_ERR_SOURCE
  390. break
  391. case 3:
  392. // MEDIA_ERR_CARRIER
  393. break
  394. case 4:
  395. // MEDIA_ERR_AUDIO
  396. break
  397. case 5:
  398. // MEDIA_ERR_VIDEO
  399. break
  400. case 6:
  401. // MEDIA_ERR_AUTHENTICATION
  402. break
  403. case 7:
  404. // MEDIA_ERR_BANDWIDTH
  405. break
  406. case 8:
  407. // MEDIA_ERR_EOF
  408. break
  409. default:
  410. // no error
  411. }
  412. </code></pre>
  413. <h3>Show/Hide Custom Error</h3>
  414. <pre><code>vxgplayer('vxg_media_player1').showerror('some error'); // show error overlay
  415. vxgplayer('vxg_media_player1').hideerror(); // hide error overlay
  416. // or
  417. var player = vxgplayer('vxg_media_player1');
  418. player.showerror('some error'); // show error overlay
  419. player.hideerror(); // hide error overlay
  420. </code></pre>
  421. <h3>Controls</h3>
  422. <pre><code>var ctrls;
  423. vxgplayer('vxg_media_player1').controls(true); // set controls to true
  424. ctrls = vxgplayer('vxg_media_player1').controls(); // get controls (return boolean value)
  425. // or
  426. var player = vxgplayer('vxg_media_player1');
  427. player.controls(true); // set controls to true
  428. ctrls = player.controls(); // get controls (return boolean value)
  429. </code></pre>
  430. <h3>Debug</h3>
  431. <pre><code>var dbg;
  432. vxgplayer('vxg_media_player1').debug(true); // set debug mode
  433. dbg = vxgplayer('vxg_media_player1').debug(); // get debug mode
  434. // or
  435. var player = vxgplayer('vxg_media_player1');
  436. player.debug(true); // set debug mode
  437. dbg = player.debug(); // get debug mode
  438. </code></pre>
  439. <h3>Mute / isMute</h3>
  440. <p>Toggle method. And Getter</p>
  441. <pre><code>var mute;
  442. vxgplayer('vxg_media_player1').mute(); // toggle mute false -&gt; true and true -&gt; false
  443. mute = vxgplayer('vxg_media_player1').isMute(); // getter
  444. // or
  445. var player = vxgplayer('vxg_media_player1');
  446. player.mute(); // toggle mute false -&gt; true and true -&gt; false
  447. mute = player.isMute(); // get state of mute
  448. </code></pre>
  449. <h3>Ready State</h3>
  450. <pre><code>// possible values of readyState:
  451. // 0 - PLAYER_STOPPED
  452. // 1 - PLAYER_CONNECTING
  453. // 2 - PLAYER_PLAYING
  454. // 3 - PLAYER_STOPPING
  455. var rs;
  456. rs = vxgplayer('vxg_media_player1').readyState();
  457. // or
  458. var player = vxgplayer('vxg_media_player1');
  459. rs = player.readyState();
  460. // example of handling by code error
  461. switch (rs) {
  462. case 0:
  463. // PLAYER_STOPPED
  464. break
  465. case 1:
  466. // PLAYER_CONNECTING
  467. break
  468. case 2:
  469. // PLAYER_PLAYING
  470. break
  471. case 3:
  472. // PLAYER_STOPPING
  473. break
  474. default:
  475. // no ready
  476. }
  477. </code></pre>
  478. <h3>Version</h3>
  479. <pre><code>var player = vxgplayer('listener2');
  480. player.versionPLG(); //version of chrome plugin
  481. player.versionAPP(); //version of VXG Media Player app
  482. </code></pre>
  483. <h3>Callback onReadyStateChange</h3>
  484. <pre><code>vxgplayer('vxg_media_player1').onReadyStateChange(function(onreadyState){
  485. console.log("player LOADED: versionPLG=" + vxgplayer('vxg_media_player1').versionPLG()+" versionAPP="+vxgplayer('vxg_media_player1').versionAPP());
  486. });
  487. // or
  488. var player = vxgplayer('listener2');
  489. player.onReadyStateChange(function(state){
  490. console.log("player LOADED: versionPLG=" + player.versionPLG()+" versionAPP="+player.versionAPP());
  491. });
  492. </code></pre>
  493. <h3>Callback onStateChange</h3>
  494. <pre><code>vxgplayer('vxg_media_player1').onStateChange(function(readyState){
  495. console.log("NEW READY STATE: " + readyState);
  496. });
  497. // or
  498. var player = vxgplayer('listener2');
  499. player.onStateChange(function(state){
  500. console.log("NEW READY STATE: " + readyState);
  501. });
  502. </code></pre>
  503. <h3>Callback onError</h3>
  504. <pre><code>vxgplayer('vxg_media_player1').onError(function(player){
  505. console.log(player.error());
  506. });
  507. // or
  508. var player = vxgplayer('vxg_media_player1');
  509. player.onError(function(player){
  510. console.log(player.error());
  511. });
  512. </code></pre>
  513. <h3>Callback onBandwidthError</h3>
  514. <pre><code>// Behaviour:
  515. // 1. If exists handler onBandwidthError then call it.
  516. // 2. If not exists then show error('Problem with bandwidth')
  517. vxgplayer('vxg_media_player1').onBandwidthError(function(player){
  518. console.log(player.error());
  519. });
  520. // or
  521. var player = vxgplayer('vxg_media_player1');
  522. player.onBandwidthError(function(player){
  523. console.log(player.error());
  524. });
  525. </code></pre>
  526. </div>
  527. </div>
  528. <script>
  529. document.addEventListener('DOMContentLoaded', function() {
  530. console.log('===player.src='+vxgplayer('vxg_media_player1').src());
  531. console.log('===player.volume()='+vxgplayer('vxg_media_player1').volume());
  532. console.log('===player.autohide()='+vxgplayer('vxg_media_player1').autohide());
  533. console.log('===player.isMute()='+vxgplayer('vxg_media_player1').isMute());
  534. console.log('===player.isPlaying()='+vxgplayer('vxg_media_player1').isPlaying());
  535. console.log('===player.autoreconnect()='+vxgplayer('vxg_media_player1').autoreconnect());
  536. vxgplayer('vxg_media_player1').onReadyStateChange(function(onreadyState){
  537. console.log("player LOADED: versionPLG=" + vxgplayer('vxg_media_player1').versionPLG()+" versionAPP="+vxgplayer('vxg_media_player1').versionAPP());
  538. vxgplayer('vxg_media_player1').play();
  539. });
  540. vxgplayer('vxg_media_player1').onError(function(onErr){
  541. console.log("player ERROR: " + vxgplayer('vxg_media_player1').error() + " decoder:"+vxgplayer('vxg_media_player1').errorDecoder());
  542. });
  543. })
  544. </script>
  545. </body>
  546. </html>