Skip to content

Commit

Permalink
Merge pull request #12 from Zibbp/develop
Browse files Browse the repository at this point in the history
Alpha 1.1.9
  • Loading branch information
Zibbp committed Sep 9, 2020
2 parents 6249f51 + f4331e4 commit fdcc253
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 254 deletions.
7 changes: 1 addition & 6 deletions api/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ const config = require("../../nuxt.config.js");
const router = Router();

if (config.default.publicRuntimeConfig.ADMIN_TOKEN) {
var adminToken = config.default.publicRuntimeConfig.ADMIN_TOKEN;
var adminToken = config.default.publicRuntimeConfig.ADMIN_TOKEN.toString();
console.log(`Admin token: ${adminToken}`);
} else {
var adminToken = crypto.randomBytes(3).toString("hex");
console.log(`Admin token: ${adminToken}`);
}

/* GET users listing. */
router.get("/auth", function(req, res, next) {
res.json({ yep: "cock" });
});

router.get("/auth/:id", function(req, res, next) {
try {
if (req.params.id === adminToken) {
Expand Down
10 changes: 0 additions & 10 deletions api/routes/test.js

This file was deleted.

38 changes: 15 additions & 23 deletions components/AdvancedControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
@open="isOpen = index"
>
<div slot="trigger" slot-scope="props" class="card-header" role="button">
<p class="card-header-title controls-title">
{{ collapse.title }}
</p>
<p class="card-header-title controls-title">{{ collapse.title }}</p>
<a class="card-header-icon has-text-white">
<b-icon :icon="props.open ? 'menu-down' : 'menu-up'"> </b-icon>
<b-icon :icon="props.open ? 'menu-down' : 'menu-up'"></b-icon>
</a>
</div>
<div class="card-content">
Expand All @@ -24,18 +22,15 @@
class="link"
href="https://github.com/zibbp/radium/wiki"
target="_blank"
>documentation</a
>
>documentation</a>
for more info.
</h6>
<div class="columns is-desktop">
<!-- SET HLS -->
<div class="column">
<form>
<label class="label has-text-white">Change HLS Stream</label>
<p v-if="hlsError" class="help is-danger">
Enter a valid HLS Url (ends with .m3u8)
</p>
<p v-if="hlsError" class="help is-danger">Enter a valid HLS Url (ends with .m3u8)</p>
<p v-else class="help has-text-white">HLS Url (.m3u8)</p>
<div class="field is-grouped">
<p class="control is-expanded">
Expand All @@ -52,9 +47,7 @@
class="button is-success"
@click.prevent="changeStream"
:disabled="!$store.state.user.admin"
>
Change
</a>
>Change</a>
</p>
</div>
</form>
Expand All @@ -63,9 +56,10 @@
<div class="column">
<form>
<label class="label has-text-white">Change Subtitles</label>
<p v-if="subtitleError" class="help is-danger">
Enter a valid subtitle Url (ends with .vtt)
</p>
<p
v-if="subtitleError"
class="help is-danger"
>Enter a valid subtitle Url (ends with .vtt)</p>
<p v-else class="help has-text-white">Subtitle Url (.vtt)</p>
<div class="field is-grouped">
<p class="control is-expanded">
Expand All @@ -82,9 +76,7 @@
class="button is-success"
@click.prevent="changeSubtitles"
:disabled="!$store.state.user.admin"
>
Change
</a>
>Change</a>
</p>
</div>
</form>
Expand All @@ -105,11 +97,11 @@ export default {
isOpen: 1,
collapses: [
{
title: "Advanced Controls"
}
title: "Advanced Controls",
},
],
subtitleUrl: "",
subtitleError: false
subtitleError: false,
};
},
mounted() {},
Expand Down Expand Up @@ -139,8 +131,8 @@ export default {
this.subtitleUrl = "";
this.subtitleError = false;
}
}
}
},
},
};
</script>

Expand Down
40 changes: 27 additions & 13 deletions components/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ export default {
"volume",
"captions",
"settings",
"fullscreen"
"fullscreen",
],
settings: ["captions", "quality", "loop"]
settings: ["captions", "quality", "loop"],
},
subtitleUrl: `${this.$config.BASE_URL}/subs.vtt`
subtitleUrl: `${this.$config.BASE_URL}/subs.vtt`,
};
},
computed: {
player() {
return this.$refs.plyr.player;
}
},
},
mounted() {
// HLS
Expand All @@ -45,15 +45,15 @@ export default {
window.hls = hls;
}
// Send player state to server for new client
this.$root.mySocket.on("requestState", id => {
this.$root.mySocket.on("requestState", (id) => {
var time = this.player.currentTime;
var state = this.player.playing;
var id = id;
var data = { time, state, id };
this.$root.mySocket.emit("sendState", data);
});
// If new client, set state from server
this.$root.mySocket.on("setState", state => {
this.$root.mySocket.on("setState", (state) => {
// Set HLS stream
if (state.roomHlsUrl) {
const hls = new Hls();
Expand Down Expand Up @@ -82,16 +82,30 @@ export default {
}
});
// change HLS stream
this.$root.mySocket.on("setStream", url => {
this.$root.mySocket.on("setStream", (url) => {
const hls = new Hls();
hls.loadSource(url);
hls.attachMedia(this.player.media);
window.hls = hls;
this.player.play();
// Toast notification
this.$buefy.toast.open({
duration: 2000,
message: `Changed HLS Stream`,
position: "is-bottom",
type: "is-success",
});
});
// change subtitles
this.$root.mySocket.on("setSubtitles", url => {
this.$root.mySocket.on("setSubtitles", (url) => {
this.subtitleUrl = url;
// Toast notification
this.$buefy.toast.open({
duration: 2000,
message: `Changed Subtitles`,
position: "is-bottom",
type: "is-success",
});
});
// Nuxt bus sync
this.$nuxt.$on("sync", () => {
Expand All @@ -103,7 +117,7 @@ export default {
this.$buefy.toast.open({
duration: 500,
message: `Play`,
position: "is-bottom"
position: "is-bottom",
});
});
// on sendPause from server
Expand All @@ -112,20 +126,20 @@ export default {
this.$buefy.toast.open({
duration: 500,
message: `Pause`,
position: "is-bottom"
position: "is-bottom",
});
});
// on sendSync from server
this.$root.mySocket.on("sendSync", currentTime => {
this.$root.mySocket.on("sendSync", (currentTime) => {
this.player.currentTime = currentTime;
this.$buefy.toast.open({
duration: 500,
message: `Syncing`,
position: "is-bottom"
position: "is-bottom",
});
});
},
methods: {}
methods: {},
};
</script>

Expand Down
Loading

0 comments on commit fdcc253

Please sign in to comment.