Add link
+
@@ -20,8 +21,9 @@
-
-
+
+
+
@@ -45,25 +47,27 @@ export default {
message: 'Add a youtube link',
trapFocus: true,
inputAttrs: {
- placeholder: 'https://www.youtube.com/watch?v=YItIK09bpKk',
- minlength: 10
+ placeholder: 'https://www.youtube.com/watch?v=YItIK09bpKk'
},
cancelText: 'Nah',
confirmText: 'Add',
onConfirm: (link) => this.addLink(link)
})
},
- addLink (link) {
+ async addLink (link) {
const linkID = this.$youtube.getIdFromUrl(link)
if (linkID === null) {
this.$buefy.toast.open('Invalid youtube link')
return
}
- this.vote(link, linkID, true)
+ const infos = await this.getInfos(linkID)
+ console.log(infos)
+ console.log(infos.title)
+ this.vote(infos.title, link, linkID, true)
},
- vote (link, linkID, isPositive) {
+ vote (title, link, linkID, isPositive) {
if (this.isAdmin) {
- this.$store.dispatch('room/vote', { link: link, linkID: linkID, isPositive: isPositive, voterName: this.$store.state.rtc.name })
+ this.$store.dispatch('room/vote', { title: title, link: link, linkID: linkID, isPositive: isPositive, voterName: this.$store.state.rtc.name })
} else {
this.sendVote(link, linkID, isPositive)
}
@@ -80,7 +84,20 @@ export default {
},
hasVoted (play) {
return play.voters.includes(this.$store.state.rtc.name)
+ },
+ removePlay (linkID) {
+ this.$store.dispatch('room/removePlay', linkID)
+ },
+ async getInfos (linkID) {
+ const response = await fetch('http://noembed.com/embed?format=json&' + 'url=https://www.youtube.com/watch?v=' + linkID)
+ return await response.json()
}
}
}
+
+
diff --git a/client/src/components/YTSearch.vue b/client/src/components/YTSearch.vue
new file mode 100644
index 0000000..676be82
--- /dev/null
+++ b/client/src/components/YTSearch.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
diff --git a/client/src/main.js b/client/src/main.js
index 6e1a96a..d9835c5 100644
--- a/client/src/main.js
+++ b/client/src/main.js
@@ -6,8 +6,8 @@ import store from './store'
import Buefy from 'buefy'
import VueYoutube from 'vue-youtube'
-import 'buefy/dist/buefy.css'
-// import './assets/style.scss'
+// import 'buefy/dist/buefy.css'
+import './assets/style.scss'
Vue.use(Buefy)
Vue.use(VueYoutube)
diff --git a/client/src/rtc.js b/client/src/rtc.js
deleted file mode 100644
index 93894fd..0000000
--- a/client/src/rtc.js
+++ /dev/null
@@ -1,205 +0,0 @@
-var name
-var connections = new Map()
-
-const configuration = {
- iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]
-}
-
-const offerOptions = {
- offerToReceiveAudio: 1,
- offerToReceiveVideo: 1
-}
-
-function handleLogin (success) {
- if (success === false) {
- alert('try a different username')
- } else {
- loginDiv.style.display = 'none'
- connectDiv.style.display = 'block'
- }
-}
-
-async function createPeerConnection (target) {
- console.log('CREATED PEER CONNECTION')
- var connection = new RTCPeerConnection(configuration)
- connections[target] = connection
-
- connection.onicecandidate = function (event) {
- if (event.candidate) {
- send({
- type: 'candidate',
- name: name,
- target: target,
- candidate: event.candidate
- })
- }
- }
-
- connection.onnegotiationneeded = function () { handleNegotiationNeededEvent(target) }
- connection.ontrack = function (event) { handleTrackEvent(event) }
- connection.onsignalingstatechange = function () { handleSignalingStateChangeEvent(connection) }
- connection.oniceconnectionstatechange = function () { handleICEConnectionStateChangeEvent(connection) }
- connection.onicegatheringstatechange = function () { handleICEGatheringStateChangeEvent(connection) }
-
- // window.setInterval(getConnectionStats, 1000)
-}
-
-function handleICEConnectionStateChangeEvent (connection) {
- console.log('ICE CONNECTION CHANGE ' + connection.iceConnectionState)
-}
-
-function handleICEGatheringStateChangeEvent (connection) {
- console.log('ICE GATHERING CHANGE ' + connection.iceGatheringState)
-}
-
-async function makeOffer (target) {
- createPeerConnection(target)
-
- var connection = connections[target]
-
- var offer = await connection.createOffer()
- send({
- type: 'offer',
- name: name,
- target: target,
- offer: offer
- })
- await connection.setLocalDescription(offer)
-
-}
-
-async function handleOffer (offer, target) {
- console.log('GOT OFFER FROM ' + target)
- await createPeerConnection(target)
-
- var connection = connections[target]
-
- await connection.setRemoteDescription(new RTCSessionDescription(offer))
-
- if (stream) {
- console.log('STREAM DETECTED')
- stream.getTracks().forEach((track) => {
- console.log('ADDED TRACK')
- connection.addTrack(track, stream)
- })
- }
-
- var answer = await connection.createAnswer()
-
- await connection.setLocalDescription(answer)
-
- send({
- type: 'answer',
- name: name,
- target: target,
- answer: answer
- })
-
- for (let user of connections.keys()) {
- console.log(user)
- }
-
- console.log('CONNECTION SIZE ' + connections.size)
-
- videoTitle.innerHTML = name + ' | ' + connections.size + ' users connected'
-}
-
-async function handleAnswer (answer, target) {
- console.log('GOT ANSWER FROM ' + target)
- var connection = connections[target]
- await connection.setRemoteDescription(new RTCSessionDescription(answer))
-}
-
-async function handleCandidate (candidate, target) {
- console.log('GOT CANDIDATE FROM ' + target)
- var connection = connections[target]
- await connection.addIceCandidate(new RTCIceCandidate(candidate))
-}
-
-async function handleNegotiationNeededEvent (target) {
- console.log('NEGOTIATION NEEDED FROM ' + target)
-
- var connection = connections[target]
- var offer = await connection.createOffer(offerOptions)
-
- await connection.setLocalDescription(offer)
-
- send({
- type: 'video-offer',
- name: name,
- target: target,
- sdp: connection.localDescription
- })
-}
-
-function handleLeave () {
- connections.forEach((connection) => {
- connection.close()
- connection = null
- })
- connections = new Map()
-
- remoteVideo.pause()
- remoteVideo.src = null
-}
-
-async function handleVideoOffer (sdp, target) {
- console.log('GOT VIDEO OFFER FROM ' + target)
- await createPeerConnection(target)
- var connection = connections[target]
- await connection.setRemoteDescription(new RTCSessionDescription(sdp))
-
- if (stream) {
- console.log('STREAM DETECTED')
- stream.getTracks().forEach((track) => {
- console.log('ADDED TRACK')
- connection.addTrack(track, stream)
- })
- }
-
- var answer = await connection.createAnswer()
- await connection.setLocalDescription(answer)
-
- send({
- type: 'video-answer',
- name: name,
- target: target,
- sdp: answer
- })
-
- // var keys = connections.keys().next().value
- videoTitle.innerHTML = name + ' | connected to ' + target
-}
-
-async function handleVideoAnswer(sdp, target) {
- console.log('GOT VIDEO ANSWER FROM ' + target)
-
- var connection = connections[target]
- await connection.setRemoteDescription(new RTCSessionDescription(sdp))
-}
-
-async function handleSignalingStateChangeEvent (connection) {
- console.log('STATE CHANGED TO : ' + connection.signalingState)
- switch(connection.signalingState) {
- case 'closed':
- await connection.close()
- break
- }
-}
-
-function handleTrackEvent (event) {
- console.log('GOT TRACK')
- remoteVideo.srcObject = event.streams[0]
- videoDiv.style.display = 'block'
- loadDiv.style.display = 'none'
-}
-
-function getConnectionStats () {
- connections.forEach((connection, target) => {
- console.log('[' + target + '] ' + connection.connectionState)
- })
-}
-
-export const rtc = {
- send
-}
diff --git a/client/src/script.js b/client/src/script.js
deleted file mode 100644
index 9b9bd4e..0000000
--- a/client/src/script.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-const loginDiv = document.querySelector('#loginDiv')
-const loginInput = document.querySelector('#loginInput')
-const loginBt = document.querySelector('#loginBt')
-
-const connectDiv = document.querySelector('#connectDiv')
-const callInput = document.querySelector('#callInput')
-const callDatalist = document.querySelector('#callDatalist')
-const callBt = document.querySelector('#callBt')
-const videoInput = document.querySelector('#videoInput')
-
-const videoDiv = document.querySelector('#videoDiv')
-const videoTitle = document.querySelector('#videoTitle')
-const remoteVideo = document.querySelector('#video')
-const disconnectBt = document.querySelector('#disconnectBt')
-
-const loadDiv = document.querySelector('#loadDiv')
-const titleDiv = document.querySelector('#titleDiv')
-
-var stream
-var users
-
-loginDiv.style.display = 'block'
-
-loginBt.addEventListener('click', function (event) {
- name = loginInput.value
-
- if (name.length > 0) {
- send({
- type: 'login',
- name: name
- })
- }
-})
-
-callBt.addEventListener('click', function () {
- var callToUsername = callInput.value;
-
- if (callToUsername.length > 0) {
- makeOffer(callToUsername)
- loadDiv.style.display = 'block'
- titleDiv.style.display = 'none'
- connectDiv.style.display = 'none'
- }
-})
-
-disconnectBt.addEventListener('click', function () {
- send({
- type: 'leave',
- name: name
- })
- handleLeave()
- videoDiv.style.display = 'none'
- loginDiv.style.display = 'block'
- titleDiv.style.display = 'block'
-})
-
-videoInput.addEventListener('change', function (event) {
- remoteVideo.src = URL.createObjectURL(this.files[0])
-
- videoDiv.style.display = 'block'
- connectDiv.style.display = 'none'
- titleDiv.style.display = 'none'
- videoTitle.innerHTML = name + ' | ' + connections.size + ' users connected'
-})
-
-remoteVideo.onplay = function () {
- console.log('ADD STREAM')
- if (remoteVideo.mozCaptureStream()) stream = remoteVideo.mozCaptureStream()
- else stream = remoteVideo.captureStream()
-}
-
-function handleUserlist(list) {
- console.log('GOT USER LIST '+list)
- users = Array.from(list)
- console.log(' users '+users)
- console.log(typeof users)
- console.log(' users '+users)
- callDatalist.innerHTML = ''
- users.forEach(user => {
- if(user != name) callDatalist.innerHTML += '
'
- })
-}
-
-function handleError(message) {
- console.log('Error '+message)
- alert(
- 'AWWW FUCK \n\n'
- +message
- +'\n\nYou should probably reload the page')
-}
-*/
diff --git a/client/src/signal.js b/client/src/signal.js
deleted file mode 100644
index 35a440f..0000000
--- a/client/src/signal.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// const conn = new WebSocket('wss://oozik.gltronic.ovh/')
-const conn = new WebSocket('wss://localhost:8080')
-
-conn.onopen = function () {
- console.log('Connected to the signaling server')
-}
-
-conn.onmessage = function (msg) {
- console.log('Got message', msg.data)
-
- var data = JSON.parse(msg.data)
-
- switch (data.type) {
- case 'login':
- handleLogin(data.success)
- break
-
- case 'offer':
- handleOffer(data.offer, data.name)
- break
-
- case 'answer':
- handleAnswer(data.answer, data.name)
- break
-
- case 'candidate':
- handleCandidate(data.candidate, data.name)
- break
-
- case 'userlist':
- handleUserlist(data.users)
- break
-
- case 'leave':
- handleLeave()
- break
-
- case 'video-offer':
- handleVideoOffer(data.sdp, data.name)
- break
-
- case 'video-answer':
- handleVideoAnswer(data.sdp, data.name)
- break
-
- case 'error':
- handleError(data.message)
- break
-
- default:
- break
- }
-}
-
-conn.onerror = function (err) {
- console.log('Got error', err)
-}
-
-function send (message) {
- console.log('Sended message', message)
- conn.send(JSON.stringify(message))
-}
-
-export const signal = {
- send
-}
diff --git a/client/src/store/roomModule.js b/client/src/store/roomModule.js
index 1067ff5..b99cf50 100644
--- a/client/src/store/roomModule.js
+++ b/client/src/store/roomModule.js
@@ -38,10 +38,11 @@ const actions = {
setTimeCode ({ commit }, timeCode) {
commit('SET_TIMECODE', timeCode)
},
- vote ({ commit, dispatch, state }, { link, linkID, isPositive, voterName }) {
+ vote ({ commit, dispatch, state }, { title, link, linkID, isPositive, voterName }) {
console.log('vote on ' + link + ' | ' + linkID + ' (' + isPositive + ') by ' + voterName)
if (isPositive) {
commit('ADD_VOTE', {
+ title: title,
linkID: linkID,
link: link,
voterName: voterName
@@ -54,6 +55,10 @@ const actions = {
}
dispatch('rtc/broadcast', { message: state.roomStatus, type: 'status' }, { root: true })
},
+ removePlay ({ commit, dispatch, state }, linkID) {
+ commit('REMOVE_PLAY', linkID)
+ dispatch('rtc/broadcast', { message: state.roomStatus, type: 'status' }, { root: true })
+ },
setCurrent ({ commit, dispatch }, { playerStatus, timeCode, timeLength, title }) {
switch (playerStatus) {
case 0:
@@ -114,10 +119,11 @@ const mutations = {
SET_CURRENTTITLE (state, title) {
state.roomStatus.current.title = title
},
- ADD_VOTE (state, { link, linkID, voterName }) {
+ ADD_VOTE (state, { title, link, linkID, voterName }) {
var play = state.roomStatus.playlist.find(play => play.linkID === linkID)
if (play === undefined) {
play = {
+ title: title,
link: link,
linkID: linkID,
votes: 1,
@@ -131,6 +137,10 @@ const mutations = {
play.votes++
play.voters.push(voterName)
}
+
+ state.roomStatus.playlist.sort((a, b) => {
+ return b.votes - a.votes
+ })
},
REMOVE_VOTE (state, { linkID, voterName }) {
var play = state.roomStatus.playlist.find(play => play.linkID === linkID)
@@ -140,12 +150,23 @@ const mutations = {
play.voters.splice(index, 1)
}
- if (play.vote === 0) {
+ if (play.votes === 0) {
const index = state.roomStatus.playlist.indexOf(play)
if (index > -1) {
state.roomStatus.playlist.splice(index, 1)
}
}
+
+ state.roomStatus.playlist.sort((a, b) => {
+ return b.votes - a.votes
+ })
+ },
+ REMOVE_PLAY (state, linkID) {
+ var play = state.roomStatus.playlist.find(play => play.linkID === linkID)
+ const index = state.roomStatus.playlist.indexOf(play)
+ if (index > -1) {
+ state.roomStatus.playlist.splice(index, 1)
+ }
},
CURRENT_END (state) {
if (state.roomStatus.playlist.length === 0) {
diff --git a/client/src/store/rtcModule.js b/client/src/store/rtcModule.js
index 2ae8354..e3b6b21 100644
--- a/client/src/store/rtcModule.js
+++ b/client/src/store/rtcModule.js
@@ -39,6 +39,9 @@ const actions = {
leave ({ commit }) {
commit('LEAVE')
},
+ kick ({ commit }, target) {
+ commit('KICK', target)
+ },
broadcast ({ commit }, { message, type }) {
commit('BROADCAST', { message: message, type: type })
}
@@ -129,6 +132,15 @@ const mutations = {
})
state.peers = []
},
+ KICK (state, target) {
+ var peer = state.peers.find(peer => peer.name === target)
+ peer.dataChannel.close()
+ peer.connection.close()
+ const index = state.peers.indexOf(peer)
+ if (index > -1) {
+ state.peers.splice(index, 1)
+ }
+ },
BROADCAST (state, { message, type }) {
const data = JSON.stringify({
type: type,
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..c7a76bb
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,10 @@
+version: '3'
+services:
+ cloud32:
+ image: gltron/c32java
+ container_name: cloud32
+ ports:
+ - 8004:8181
+ volumes:
+ - /data/c32_data/:/data
+ restart: unless-stopped
\ No newline at end of file