Skip to content

Commit

Permalink
fixed live server
Browse files Browse the repository at this point in the history
fixed live server
  • Loading branch information
qieangel2013 committed Dec 13, 2016
1 parent 647905d commit ff25661
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
34 changes: 30 additions & 4 deletions application/views/index/swoolelive.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</style>
</head>
<body>
<audio id="audio" src="">
<audio id="audio" autoplay="autoplay">
</audio>
<div id="chat"></div>
<script src="/public/vue/vue.js"></script>
Expand All @@ -46,6 +46,32 @@
//var receiver_socket = new WebSocket("wss://"+document.domain+":9503");
var image = document.getElementById('receiver');
var audio = document.querySelector('audio');
window.initPlayer = function(obj){
obj.playlist = []; //播放列表
obj.position = 0; //当前播放位置
//播放音乐(循环播放)
obj.start = function(){
if(jQuery.isArray(obj.playlist) && obj.playlist.length>=1){
$(obj).attr("src", obj.playlist[obj.position % obj.playlist.length]);
obj.play();
}
};
//播放一个列表
obj.playList = function(arr){
if(jQuery.isArray(arr) && arr.length>=1){
obj.playlist = arr;
obj.position = 0;
obj.start();
}
};
//播放下一首
$(obj).on("ended",function(e){
obj.playlist.shift();
//obj.position++;
obj.start();
});
};
initPlayer(audio);
receiver_socket.onmessage = function(data)
{
zqfdata= jQuery.parseJSON(data.data);
Expand All @@ -60,10 +86,10 @@
//console.log(zqfdata.data);
//console.log(window.URL.createObjectURL(blob));
//$('#audio').attr('src',zqfdata.data);

audio.src =zqfdata.data;
audio.playlist.push(zqfdata.data);
//audio.src =zqfdata.data;
if(audio.paused){
audio.play();
audio.start();
}
/*g_audio.elems["id"] = '';
g_audio.push({
Expand Down
2 changes: 1 addition & 1 deletion application/views/index/swoolelivecamera.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
//压缩
var compression = parseInt(this.inputSampleRate / this.outputSampleRate);
var length = data.length / compression;
console.log(length);
//console.log(length);
var result = new Float32Array(parseInt(length));
var index = 0, j = 0;
while (index < length) {
Expand Down

0 comments on commit ff25661

Please sign in to comment.