index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // vDecoder example
  2. import { VDecoder } from "./VDecoder.js";
  3. // 测试用
  4. import { initWebGLCanvas, draw } from "../video/test.js";
  5. // decoder
  6. const socket = io("ws://192.168.0.150:3000", {
  7. reconnectionDelayMax: 10000,
  8. });
  9. socket.on("connect", (data) => {
  10. console.log("socket connect");
  11. });
  12. const vDecoder = new VDecoder({
  13. maxChip: 100,
  14. });
  15. vDecoder.on("ready", () => {
  16. console.log("ready");
  17. // 测试canvas
  18. initWebGLCanvas();
  19. vDecoder.fetch({
  20. path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
  21. range: [0, 66],
  22. });
  23. vDecoder.on("fetchDone", (clip) => {
  24. console.log("fetchDone", clip);
  25. });
  26. //监听 decodeData
  27. vDecoder.on("decodeData", (data) => {
  28. // console.log("decodeData", data);
  29. const { width, height, data: buffer } = data;
  30. // draw(new Uint8Array(buffer), width, height);
  31. // window.updateTexture( new Uint8Array(buffer) );
  32. // window.up
  33. });
  34. vDecoder.on("decodeDone", async (id) => {
  35. let clipId = null;
  36. // vDecoder.flush();
  37. // vDecoder.fetch({
  38. // path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
  39. // range: [0, 66],
  40. // });
  41. // console.log("clipId", clipId);
  42. });
  43. });