Skip to content

Instantly share code, notes, and snippets.

View MTDdk's full-sized avatar

Anders MTDdk

View GitHub Profile
@MTDdk
MTDdk / IceCastMetaData.java
Last active November 12, 2020 01:03
Continously extract StreamTitle (MP3 metadata) from SHOUTcast / IceCast audio streaming
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
/**
@MTDdk
MTDdk / audiohandling-with-location-search.js
Last active August 29, 2018 11:09
Use spacebar to pause/play audio on a HTML5 page + get timestring from location.search
/*
* Use keyboard shortcuts to handle <audio> tags.
* - space : Pauses the player on the site
* - left arrow : Reel the audio 10 seconds back in time
* - right arrow : Reel the audio 10 seconds forth in time
*/
var player = document.getElementById('player')
if (player) {
@MTDdk
MTDdk / audiohandling.js
Last active November 2, 2021 08:06
Use spacebar to pause/play audio on a HTML5 page
var audio = document.querySelector('audio');
if (audio) {
window.addEventListener('keydown', function (event) {
var key = event.which || event.keyCode;
if (key === 32) { // spacebar