Commit bf21f5db authored by likely's avatar likely

跑通安卓

parent 93fd5f08
...@@ -3,6 +3,7 @@ var ios = require('./libs/ios'); ...@@ -3,6 +3,7 @@ var ios = require('./libs/ios');
var android = require('./libs/android'); var android = require('./libs/android');
import './less/index.less' import './less/index.less'
import toast from 'in-toast' import toast from 'in-toast'
import './utils/zepto'
new TcPlayer('lvb', { new TcPlayer('lvb', {
"m3u8": "http://14246.liveplay.myqcloud.com/live/14246_055dd098ab729831abff0c1f55536403.m3u8 ", "m3u8": "http://14246.liveplay.myqcloud.com/live/14246_055dd098ab729831abff0c1f55536403.m3u8 ",
...@@ -23,33 +24,61 @@ if (/iphone|ipad|ipod/gi.test(ua)) { ...@@ -23,33 +24,61 @@ if (/iphone|ipad|ipod/gi.test(ua)) {
insert('//sqimg.qq.com/expert_qq/webrtc/1.2/WebRTCAPI.min.js', android); insert('//sqimg.qq.com/expert_qq/webrtc/1.2/WebRTCAPI.min.js', android);
} }
var btnPlay = document.querySelector('.play') var exampleSocket = new WebSocket("ws://www.example.com/socketserver")
var wheel = document.querySelector('.wheel')
var btnDown = document.querySelector('.down')
var vLvb = document.querySelector('#lvb')
btnPlay.addEventListener('click', start) exampleSocket.onopen = function(event) {
btnDown.addEventListener('click', () => { exampleSocket.send("Here's some text that the server is urgently awaiting!");
};
exampleSocket.onmessage = function(event) {
console.log(event.data);
}
//ui操作
var btnPlay = $('.play'),
wheel = $('.wheel'),
btnDown = $('.down'),
vLvb = $('#lvb'),
front = $('.front').eq(0),
front_width = front.clientWidth,
front_height = front.clientHeight
// $('.front video,.front canvas').css('width', front_height)
btnPlay.on('click', start)
btnDown.on('click', () => {
toast('1.2秒后结束游戏...') toast('1.2秒后结束游戏...')
setTimeout(end, 1200) setTimeout(end, 1200)
}) })
function start() { function start() {
show.call(wheel) wheel.show()
hide.call(btnPlay) btnPlay.hide()
hide.call(vLvb) vLvb.hide()
} }
function end() { function end() {
show.call(btnPlay) wheel.hide()
show.call(vLvb) btnPlay.show()
hide.call(wheel) vLvb.show()
} }
function show() { $('.top').on('click', function() {
this.style.display = 'block'
} })
$('.right').on('click', function() {
})
$('.bottom').on('click', function() {
})
$('.left').on('click', function() {
})
$('.down').on('click', function() {
function hide() { })
this.style.display = 'none' \ No newline at end of file
}
\ No newline at end of file
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
} }
@color: rgba(250, 206, 1, .9); @color: rgba(250, 206, 1, .9);
@front_width: 450;
@front_height: @front_width*4/3;
body { body {
background-color: rgba(255, 239, 161, 1); background-color: rgba(255, 239, 161, 1);
...@@ -21,8 +23,8 @@ body { ...@@ -21,8 +23,8 @@ body {
} }
.front { .front {
.size(500, 700); .size(@front_width, @front_height);
.pos(125, 100); .pos((750+-@front_width) / 2, 100);
overflow: hidden; overflow: hidden;
} }
...@@ -106,10 +108,16 @@ body { ...@@ -106,10 +108,16 @@ body {
canvas, canvas,
#lvb, #lvb,
#lvb video { #lvb video,
.front video {
width: 100%; width: 100%;
height: 100%; height: 100%;
.pos(0, 0); // .pos(0, 0);
}
#lvb video,
.front video {
transform: rotate(-270deg)
} }
#lvb { #lvb {
......
...@@ -24,15 +24,18 @@ module.exports = function() { ...@@ -24,15 +24,18 @@ module.exports = function() {
} else { } else {
//创建房间 //创建房间
WebRTCAPI.createRoom({ WebRTCAPI.createRoom({
roomid: RoomNumber, roomid: 59,
role: Role role: 'LiveGuest'
}, onCreateRoomCallback); }, function(result) {
console.log(result)
});
} }
}, },
onLocalStreamAdd: function(e) { onLocalStreamAdd: function(e) {
}, },
onRemoteStreamAdd: function(stream, videoId) { onRemoteStreamAdd: function(stream, videoId) {
console.log(stream, videoId)
var videoElement = document.getElementById("remoteVideo"); var videoElement = document.getElementById("remoteVideo");
videoElement.srcObject = stream; videoElement.srcObject = stream;
}, },
...@@ -44,10 +47,7 @@ module.exports = function() { ...@@ -44,10 +47,7 @@ module.exports = function() {
}, },
onUpdateRemoteStream: function(stream, videoId, type, ssrState, openId) { onUpdateRemoteStream: function(stream, videoId, type, ssrState, openId) {
var videoElement = document.getElementById(videoId); this.onRemoteStreamAdd(stream, videoId, openId);
videoElement.parentNode.removeChild(videoElement)
//这里调用remotestreamadd的回调函数
onRemoteStreamAdd(stream, videoId, openId);
}, },
onKickout: function() { onKickout: function() {
alert("其他地方登录,被T下线") alert("其他地方登录,被T下线")
...@@ -67,9 +67,10 @@ module.exports = function() { ...@@ -67,9 +67,10 @@ module.exports = function() {
} }
}, { }, {
openid: "1574", openid: "1585",
sdkAppId: 1400050371, sdkAppId: 1400050371,
accountType: 19242, accountType: 19242,
userSig: "eJxFkFFPgzAUhf8LrzNyCytVEx-qYGQGE8fAZHtpKnTkOmEddAM0-neRjPh6vtyc79xvK4k2t1JrzIU0wq1z68EC62aMVaexVkLujaqHmFBKHYCJXlTd4LEagAOEEscF*IeYq8rgHsdDzjm9v4IGiyF5CdLFyk-t*LCLi26RaB9ksA6Lks1t8hSuGnnq4*VH28PsEpEy4xjw1t62Jf1iBN8*qyXwu-dot-UTrzinJx2Em3XCQxV3s*dX-jiV5Qcxbvuznw92FFxGrtBgqcZVxGOeS9lkKLPseK6MML1W4zN*fgGy2FYp", closeLocalMedia: true,
userSig: "eJxFkF1PgzAUQP8Lr5itLe1qTHyAjTEnIzFjXXxqyFrkbvIhtFNi-O8iYfH1nNzcc**3k8b7WdY0oGRmpNcq58FBzt2I9VcDrZZZbnQ7YMwYIwjd7FW3HdTVIAjCDBMPoX8JSlcGcpgG79nEO3gbwC48LJ8iteYHunG37D0-0nPpJoEV5TY4NpammzylHCI8Xy8TX-gQ*vZj8VlEzIW56M-7uCb8uuoRR4H-Ghf2IsLi2QY78ZLo7vG2TF3keNpfAx3iGPI4nqSBUo9teME54YROPDudalsZafpGj7-4*QXQ01T-",
}) })
} }
\ No newline at end of file
function player(url) {
this.ws = new WebSocket(url)
this.ws.onopen = function(event) {
this.ws.send("Here's some text that the server is urgently awaiting!");
};
this.ws.onmessage = function(event) {
console.log(event.data);
}
}
player.prototype.send = function() {
}
module.exports = player
\ No newline at end of file
function zepto(s) {
this.ele = document.querySelectorAll(s)
this.length = this.ele.length
}
function each(callback) {
this.forEach(function(item, index) {
callback(item, index)
})
}
zepto.prototype.show = function() {
each.call(this.ele, function(item) {
item.style.display = 'block'
})
return this.ele
}
zepto.prototype.hide = function() {
each.call(this.ele, function(item) {
item.style.display = 'none'
})
return this.ele
}
zepto.prototype.on = function(event, callback) {
each.call(this.ele, function(item) {
item.addEventListener(event, callback)
})
return this.ele
}
zepto.prototype.css = function(property, value) {
each.call(this.ele, function(item) {
item.style[property] = value
})
return this.ele
}
zepto.prototype.eq = function(index) {
return this.ele[index]
}
zepto.prototype.height = function() {
return this.style.height
}
window.$ = (selector) => {
return new zepto(selector)
}
export default window.$
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment