livetalking/test.html

68 lines
3.4 MiB
HTML
Raw Normal View History

2023-12-19 09:41:52 +08:00
<!-- index.html -->
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.3.0/video-js.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.3.0/video.min.js"></script>
<script type="text/javascript" src="http://cdn.sockjs.org/sockjs-0.3.4.js"></script>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
<div class="container">
<h1>WebSocket Test</h1>
<form class="form-inline" id="echo-form">
<div class="form-group">
<p>数据输入的参数格式</p>
<textarea cols="2" rows="6" style="width:600px;height:200px;" class="form-control" id="message">
{
"Topic": "Unreal",
"Data": {
"Key": "audio",
"Value": "D:\coding\NeRF\xuniren\aispeech\data\audio\aud_1.wav",
"Time": 10,
"Type": "interact"
}
}
</textarea>
</div>
<button type="submit" class="btn btn-default">Send</button>
</form>
<div id="log">
</div>
<video id="example_video" controls="controls" ></video>
</div>
</body>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var ws = new WebSocket('ws://39.106.151.142:8000/dighuman');
//aa = {"video": "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAooM1tZGF0AAACoQYF//+d3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE1OSAtIEguMjY0L01QRUctNCBBVkMgY29kZWMgLSBDb3B5bGVmdCAyMDAzLTIwMTkgLSBodHRwOi8vd3d3LnZpZGVvbGFuLm9yZy94MjY0Lmh0bWwgLSBvcHRpb25zOiBjYWJhYz0xIHJlZj0zIGRlYmxvY2s9MTowOjAgYW5hbHlzZT0weDM6MHgxMTMgbWU9aGV4IHN1Ym1lPTcgcHN5PTEgcHN5X3JkPTEuMDA6MC4wMCBtaXhlZF9yZWY9MSBtZV9yYW5nZT0xNiBjaHJvbWFfbWU9MSB0cmVsbGlzPTEgOHg4ZGN0PTEgY3FtPTA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9knmr1LAfSCUfB9tvNveffPVXWh8mutmSiJ2yKhRSprP7WtoaB0QWYJIcWxRuxa0TraZzfVwu+tu5HArGz1aTliHydYZ0WIGQLI0HSDv7usRmWVMQywHuex1aJ9+yY7RchkxzbMzx1wQeaB+puttJoXTeysL0u6sdAS6HyG4D4BeiSy8V9rGvAX0gmSilbOM0hwkaowKMoPtG1bH3QCD7rEU7/CSmHXwnWV9eNFryI8LPTzOSzwDKdnfEm1xWpoSWWqJ/AhFaR3CxvNyM9ptyr3NnaFu8hUTUHiCdci8ZuDS7dGV2gCxPFxZIT7bFUCEqA1ffjMAMrrYX341GHY3RsFSTY+jRDUsJ46CI1SYRLWbHbx+MUmY1zJPzeJJ
//document.getElementsByTagName("video")[0].setAttribute("src", aa["video"]);
ws.onopen = function() {
console.log('Connected');
};
ws.onmessage = function(e) {
console.log('Received: ' + e.data);
data = e
var vid = JSON.parse(data.data);
console.log(typeof(vid),vid)
document.getElementsByTagName("video")[0].setAttribute("src", vid["video"]);
};
ws.onclose = function(e) {
console.log('Closed');
};
$('#echo-form').on('submit', function(e) {
e.preventDefault();
var message = $('#message').val();
console.log('Sending: ' + message);
ws.send(message);
$('#message').val('');
});
});
</script>
</html>