|
| 1 | +import { init as initVision, login, logout, startRealPlay, stopRealPlay, dispose as disposeVision } from '../hikvision.js'; |
| 2 | +import EventHandler from '../../BootstrapBlazor/modules/event-handler.js'; |
| 3 | + |
| 4 | +export async function init(id) { |
| 5 | + const el = document.getElementById(id); |
| 6 | + if (el === null) { |
| 7 | + return; |
| 8 | + } |
| 9 | + |
| 10 | + const previewId = `${id}_preview`; |
| 11 | + await initVision(previewId); |
| 12 | + |
| 13 | + const controls = el.querySelector('.bb-hik-controls'); |
| 14 | + if (controls) { |
| 15 | + EventHandler.on(controls, 'click', '.bb-hik-login', async e => { |
| 16 | + console.log('login'); |
| 17 | + await login(previewId, '47.121.113.151', 9980, 'admin', 'vhbn8888', 1) |
| 18 | + }); |
| 19 | + EventHandler.on(controls, 'click', '.bb-hik-logout', e => { |
| 20 | + console.log('logout'); |
| 21 | + logout(previewId); |
| 22 | + }); |
| 23 | + EventHandler.on(controls, 'click', '.bb-hik-start', e => { |
| 24 | + console.log('start'); |
| 25 | + startRealPlay(previewId); |
| 26 | + }); |
| 27 | + EventHandler.on(controls, 'click', '.bb-hik-stop', e => { |
| 28 | + console.log('stop'); |
| 29 | + stopRealPlay(previewId); |
| 30 | + }); |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +export function dispose(id) { |
| 35 | + const el = document.getElementById(id); |
| 36 | + if (el !== null) { |
| 37 | + const controls = el.querySelector('.bb-hik-controls'); |
| 38 | + if (controls) { |
| 39 | + EventHandler.off(controls, 'click'); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + const previewId = `${id}_preview`; |
| 44 | + disposeVision(previewId); |
| 45 | +} |
0 commit comments