demo-requirejs.html 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title></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="Cache-Control" content="no-cache, must-revalidate" />
  8. <meta http-equiv="Expires" content="0" />
  9. </head>
  10. <style>
  11. .plugin {
  12. width: 600px;
  13. height: 400px;
  14. }
  15. </style>
  16. <body>
  17. <div>
  18. <div id="divPlugin" class="plugin"></div>
  19. </div>
  20. </body>
  21. <script src="../jquery-1.7.1.min.js"></script>
  22. <script src="../require-2.3.3.min.js"></script>
  23. <script>
  24. require.config({
  25. baseUrl: "./"
  26. });
  27. require(["../codebase/webVideoCtrl"], function (WebVideoCtrl) {
  28. // 检查插件是否已经安装过
  29. var iRet = WebVideoCtrl.I_CheckPluginInstall();
  30. if (-1 == iRet) {
  31. alert("您还未安装过插件,双击开发包目录里的WebComponentsKit.exe安装!");
  32. return;
  33. }
  34. var oPlugin = {
  35. iWidth: 600, // plugin width
  36. iHeight: 400 // plugin height
  37. };
  38. var oLiveView = {
  39. iProtocol: 1, // protocol 1:http, 2:https
  40. szIP: "172.10.18.59", // protocol ip
  41. szPort: "80", // protocol port
  42. szUsername: "admin", // device username
  43. szPassword: "12345678q", // device password
  44. iStreamType: 1, // stream 1:main stream 2:sub-stream 3:third stream 4:transcode stream
  45. iChannelID: 1, // channel no
  46. bZeroChannel: false // zero channel
  47. };
  48. // 初始化插件参数及插入插件
  49. WebVideoCtrl.I_InitPlugin(oPlugin.iWidth, oPlugin.iHeight, {
  50. szBasePath: "../codebase/",
  51. bWndFull: true,//是否支持单窗口双击全屏,默认支持 true:支持 false:不支持
  52. iWndowType: 1,
  53. cbInitPluginComplete: function () {
  54. WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin");
  55. // 检查插件是否最新
  56. if (-1 == WebVideoCtrl.I_CheckPluginVersion()) {
  57. alert("检测到新的插件版本,双击开发包目录里的WebComponentsKit.exe升级!");
  58. return;
  59. }
  60. // 登录设备
  61. WebVideoCtrl.I_Login(oLiveView.szIP, oLiveView.iProtocol, oLiveView.szPort, oLiveView.szUsername, oLiveView.szPassword, {
  62. success: function (xmlDoc) {
  63. // 开始预览
  64. var szDeviceIdentify = oLiveView.szIP + "_" + oLiveView.szPort;
  65. setTimeout(function () {
  66. WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
  67. iStreamType: oLiveView.iStreamType,
  68. iChannelID: oLiveView.iChannelID,
  69. bZeroChannel: oLiveView.bZeroChannel
  70. });
  71. }, 1000);
  72. }
  73. });
  74. }
  75. });
  76. // 关闭浏览器
  77. $(window).unload(function () {
  78. WebVideoCtrl.I_Stop();
  79. });
  80. });
  81. </script>
  82. </html>