websocket.js 698 B

12345678910111213141516171819202122232425262728293031
  1. self.importScripts("helper.js");
  2. // self.importScripts("pcm-player.js");
  3. // self.importScripts("pcm-player.min.js");
  4. var socketURL = "ws://192.168.198.11:9101";
  5. // var socketURL = "ws://14.215.128.98:14102"
  6. // socketURL = "ws://127.0.0.1:8081"
  7. var ws = new WebSocket(socketURL);
  8. ws.binaryType = 'arraybuffer';
  9. ws.addEventListener('open', function(event) {
  10. console.log("发送配置帧");
  11. ws.send(ConfigChannel("RK3923C1201900139"));
  12. });
  13. ws.addEventListener('message', function(event) {
  14. //var objData = {type:0, data:input};
  15. var input = new Uint8Array(event.data);
  16. if (input[0] == 0xff) {
  17. console.log("1111111")
  18. // decodeAAC(input);
  19. } else {
  20. self.postMessage(input);
  21. }
  22. });