demo-iframe.html 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. <style type="text/css">
  10. iframe {
  11. margin: 0;
  12. padding: 0;
  13. border: 0;
  14. width: 300px;
  15. height: 200px;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div>
  21. <iframe src="iframe.html" frameborder="0" onload="iframeLoaded();"></iframe>
  22. <iframe src="iframe.html" frameborder="0" onload="iframeLoaded();"></iframe>
  23. </div>
  24. <div>
  25. <iframe src="iframe.html" frameborder="0" onload="iframeLoaded();"></iframe>
  26. <iframe src="iframe.html" frameborder="0" onload="iframeLoaded();"></iframe>
  27. </div>
  28. </body>
  29. <script src="../jquery-1.7.1.min.js"></script>
  30. <script src="../codebase/webVideoCtrl.js"></script>
  31. <script>
  32. var g_aIframe = $("iframe");
  33. $(function () {
  34. // ������Ƿ��Ѿ���װ��
  35. var iRet = WebVideoCtrl.I_CheckPluginInstall();
  36. if (-1 == iRet) {
  37. alert("����δ��װ�������˫��������Ŀ¼���WebComponentsKit.exe��װ��");
  38. return;
  39. }
  40. // �ر������
  41. $(window).unload(function () {
  42. $.each(g_aIframe, function (i, oIframe) {
  43. getWebVideoCtrl(oIframe).I_Stop();
  44. });
  45. });
  46. });
  47. var iLoadedCount = 0;
  48. function iframeLoaded() {
  49. iLoadedCount++;
  50. if (4 === iLoadedCount) {
  51. var oLiveView = {
  52. iProtocol: 1, // protocol 1��http, 2:https
  53. szIP: "172.10.18.59", // protocol ip
  54. szPort: "80", // protocol port
  55. szUsername: "admin", // device username
  56. szPassword: "12345678q", // device password
  57. iStreamType: 2, // stream 1��main stream 2��sub-stream 3��third stream 4��transcode stream
  58. iChannelID: 1, // channel no
  59. bZeroChannel: false // zero channel
  60. };
  61. $.each(g_aIframe, function (i, oIframe) {
  62. var oWebVideoCtrl = getWebVideoCtrl(oIframe);
  63. console.log(oIframe)
  64. console.log($("iframe")[0])
  65. console.log($("iframe")[0]===oIframe)
  66. // ��¼�豸
  67. oWebVideoCtrl.I_Login(oLiveView.szIP, oLiveView.iProtocol, oLiveView.szPort, oLiveView.szUsername, oLiveView.szPassword, {
  68. success: function (xmlDoc) {
  69. // ��ʼԤ��
  70. var szDeviceIdentify = oLiveView.szIP + "_" + oLiveView.szPort;
  71. setTimeout(function () {
  72. oWebVideoCtrl.I_StartRealPlay(oLiveView.szIP, {
  73. iStreamType: oLiveView.iStreamType,
  74. iChannelID: oLiveView.iChannelID,
  75. bZeroChannel: oLiveView.bZeroChannel
  76. });
  77. }, 1000);
  78. }
  79. });
  80. });
  81. }
  82. }
  83. function getWebVideoCtrl(oIframe) {
  84. return oIframe.contentWindow.WebVideoCtrl;
  85. }
  86. </script>
  87. </html>