Refactor MediaPlayer, adds login sound
Logingeluidje werkt waarschijnlijk bij niemand, maar leuke easter egg
This commit is contained in:
Binary file not shown.
@@ -11,8 +11,7 @@ body {
|
||||
z-index:99;
|
||||
min-height: 520px;
|
||||
width:560px;
|
||||
overflow-y:scroll;
|
||||
overflow-x:hidden;
|
||||
overflow:hidden;
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
justify-content: space-between;
|
||||
@@ -154,22 +153,13 @@ iframe {
|
||||
width: 256px;
|
||||
}
|
||||
|
||||
input[type="range"] {
|
||||
margin: 8px 0;
|
||||
#seek {
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
input[type="range"]::-moz-range-track {
|
||||
background: #aaa;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
input[type="range"]::-moz-range-thumb {
|
||||
height: 15px;
|
||||
width: 15px;
|
||||
transform: unset;
|
||||
background: transparent;
|
||||
border: 3px solid lightgray;
|
||||
border-bottom-color: darkgrey;
|
||||
#media-control button {
|
||||
min-width: 0;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
/* Clippy */
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
{% include "head.html" %}
|
||||
</head>
|
||||
<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
|
||||
<script>setWallpaper()</script>
|
||||
<div class="window" id="main-window">
|
||||
<div class="title-bar main-title-bar">
|
||||
<div class="title-bar-text">
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
{% include "head.html" %}
|
||||
</head>
|
||||
<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
|
||||
<script>setWallpaper()</script>
|
||||
<script>
|
||||
a = new Audio("{% static 'startup.wav' %}");
|
||||
a.volume = 0.5;
|
||||
a.play();
|
||||
</script>
|
||||
<div class="window popup login" id="info-window">
|
||||
<div class="title-bar">
|
||||
<div class="title-bar-text">Welkom bij Muzak</div>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<div id="embed"></div>
|
||||
<div id="album">
|
||||
{% if track.album.image %}
|
||||
<img src="{{track.album.image.url}}" />
|
||||
{% elif track.album.image_url %}
|
||||
<img src="{{track.album.image_url}}" />
|
||||
{% else %}
|
||||
<img src="https://kagi.com/proxy/windows-95-logo-png-1.png?c=xjdP8sWN58YWflc6NcGN5ZvzREJyOwtrou-TSsaXxcx37J0VVJbSeycOcAptMJEUpzzvqmbKQ3JRuSmPN8HCK43OxjkRe_cQvncxVzlCblc%3D" />
|
||||
{% endif %}
|
||||
<h1 title="{{track.name}}">{{track.name}}</h1>
|
||||
<h2 title="{{track.artist}}">{{track.artist}}</h2>
|
||||
</div>
|
||||
<input id="seek" type="range" min="0" step="0.1" max="100" value="0" />
|
||||
<div id="media-control">
|
||||
<button id="play">></button>
|
||||
<button id="pause">||</button>
|
||||
<button id="stop">[]</button>
|
||||
</div>
|
||||
<script>
|
||||
window.onSpotifyIframeApiReady = (IFrameAPI) => {
|
||||
let element = document.getElementById('embed');
|
||||
let options = {
|
||||
uri: 'spotify:track:{{track.id}}'
|
||||
};
|
||||
const callback = (EmbedController) => {
|
||||
document.getElementById("play").addEventListener('click', () => {
|
||||
EmbedController.play()
|
||||
});
|
||||
EmbedController.addListener('playback_update', e => {
|
||||
document.getElementById('seek').value = `${parseInt(e.data.position) / parseInt(e.data.duration) * 100}`;
|
||||
})
|
||||
};
|
||||
IFrameAPI.createController(element, options, callback);
|
||||
};
|
||||
</script>
|
||||
@@ -25,20 +25,7 @@
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button id="wallpaper-reset" onclick="wallpaperChanged()">Reset</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
<script>
|
||||
function wallpaperChanged() {
|
||||
const expression = /^https?:\/\/.*\.(jpeg|jpg|png|gif)$/
|
||||
const regex = new RegExp(expression)
|
||||
val = document.getElementById("wallpaper").value
|
||||
if(regex.test(val)) {
|
||||
console.log(val)
|
||||
localStorage.setItem("wallpaper", val);
|
||||
setWallpaper()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -8,22 +8,7 @@ Stemmen
|
||||
{% if track %}
|
||||
<div id="vote-box" hx-target="body">
|
||||
{% if error %}<div class="error">{{ error }}</div>{% endif %}
|
||||
<div id="embed"></div>
|
||||
<div id="album">
|
||||
{% if track.album.image %}
|
||||
<img src="{{track.album.image.url}}" />
|
||||
{% elif track.album.image_url %}
|
||||
<img src="{{track.album.image_url}}" />
|
||||
{% else %}
|
||||
<img src="https://kagi.com/proxy/windows-95-logo-png-1.png?c=xjdP8sWN58YWflc6NcGN5ZvzREJyOwtrou-TSsaXxcx37J0VVJbSeycOcAptMJEUpzzvqmbKQ3JRuSmPN8HCK43OxjkRe_cQvncxVzlCblc%3D" />
|
||||
{% endif %}
|
||||
<h1 title="{{track.name}}">{{track.name}}</h1>
|
||||
<h2 title="{{track.artist}}">{{track.artist}}</h2>
|
||||
</div>
|
||||
<input id="seek" type="range" min="0" step="0.1" max="100" value="0" />
|
||||
<div class="media-control">
|
||||
<button id="playpause">⏵️</button>
|
||||
</div>
|
||||
{% include 'MediaPlayer.html' with track=track %}
|
||||
|
||||
<div
|
||||
id="vote-stars"
|
||||
@@ -65,23 +50,6 @@ Stemmen
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
window.onSpotifyIframeApiReady = (IFrameAPI) => {
|
||||
let element = document.getElementById('embed');
|
||||
let options = {
|
||||
uri: 'spotify:track:{{track.id}}'
|
||||
};
|
||||
const callback = (EmbedController) => {
|
||||
document.getElementById("playpause").addEventListener('click', () => {
|
||||
EmbedController.togglePlay()
|
||||
});
|
||||
EmbedController.addListener('playback_update', e => {
|
||||
document.getElementById('seek').value = `${parseInt(e.data.position) / parseInt(e.data.duration) * 100}`;
|
||||
})
|
||||
};
|
||||
IFrameAPI.createController(element, options, callback);
|
||||
};
|
||||
</script>
|
||||
{% else %}
|
||||
<p hx-boost="true">
|
||||
Je hebt niets meer om te stemmen. Lekker bezig!
|
||||
|
||||
@@ -45,12 +45,4 @@
|
||||
localStorage.removeItem("position")
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function setWallpaper() {
|
||||
url = localStorage.getItem("wallpaper")
|
||||
if (url)
|
||||
document.body.style.backgroundImage = "url(" + url + ")";
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user