demo-seajs.html 3.2 KB

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