From 0f58eb33a6fab4a99462a44a7cbec5a15f2f8e1c Mon Sep 17 00:00:00 2001 From: Ralph Caraveo Date: Sat, 13 Jun 2015 22:38:41 -0700 Subject: [PATCH] Added go server to serve the content. --- html5/HTML5-CDGPlayer.htm | 7 +++++++ html5/cdgmagic_cdgplayer.js | 5 +++-- html5/karaoke-server.go | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 html5/karaoke-server.go diff --git a/html5/HTML5-CDGPlayer.htm b/html5/HTML5-CDGPlayer.htm index 644b714..9d3d754 100644 --- a/html5/HTML5-CDGPlayer.htm +++ b/html5/HTML5-CDGPlayer.htm @@ -91,6 +91,13 @@ function toggle_2x_mode() + + + + + + +

This JavaScript based player should work in most HTML5 compatible browsers supporting both the <canvas> and <audio> (note: "Sample Project" 01-04 are silent) tags, including many mobile and embedded devices. diff --git a/html5/cdgmagic_cdgplayer.js b/html5/cdgmagic_cdgplayer.js index c4aed48..b970820 100644 --- a/html5/cdgmagic_cdgplayer.js +++ b/html5/cdgmagic_cdgplayer.js @@ -64,8 +64,9 @@ function set_file_prefix(file_url_prefixes) // Ignore this call if we weren't given a file name. if (file_url_prefixes == "") { return; }; // Construct the file paths. - var audio_file_prefix = file_url_prefixes.split(":", 2)[0]; - var cdg_file_prefix = file_url_prefixes.split(":", 2)[1]; + // Ensure the subfolder below: karaoke/ has the cdg/mp3 media files + var audio_file_prefix = "karaoke/" + file_url_prefixes.split(":", 2)[0]; + var cdg_file_prefix = "karaoke/" + file_url_prefixes.split(":", 2)[1]; // Prepend the media files source directoy. // file_url_prefix = "media/" + file_url_prefix; // Stop, reset, and blank all the CD+G related stuff. diff --git a/html5/karaoke-server.go b/html5/karaoke-server.go new file mode 100644 index 0000000..7164663 --- /dev/null +++ b/html5/karaoke-server.go @@ -0,0 +1,18 @@ +package main + +import ( + "log" + "net/http" +) + +func main() { + http.Handle("/", http.FileServer(http.Dir("."))) + + // To serve a directory on disk (/tmp) under an alternate URL + // path (/tmpfiles/), use StripPrefix to modify the request + // URL's path before the FileServer sees it: + // This handler serves only the karaoke content + http.Handle("/karaoke/", http.StripPrefix("/karaoke/", http.FileServer(http.Dir("./karaoke/")))) + + log.Fatal(http.ListenAndServe(":8080", nil)) +}