html - source an audio file in repo on github pages -
i'm hosting project on github pages , play audio file located in repository through html5 <audio>
element. when source on dev environment, audio plays fine, when push gh-pages 404 console error cannot found.
<audio ref='themesong' src="vendor/assets/music/tetris.mp3" autoplay loop></audio>
error:
get http://myname.github.io/vendor/assets/music/tetris.mp3 404 (not found)
i've tried sourcing this:
"vendor/assets/music/tetris.mp3" "/vendor/assets/music/tetris.mp3" "http://github.com/myname/myrepo/vendor/assets/music/tetris.mp3" "http://github.com/myname/myrepo/tree/master/vendor/assets/music/tetris.mp3"
but nothing seems work.
you can try , reference raw url
https://raw.githubusercontent.com/myname/myrepo/master/vendor/assets/music/tetris.mp3
note: service rawgit.com mentions:
when request file
raw.githubusercontent.com
orgist.githubusercontent.com
, github serves (in case of javascript, html, css, , other file types)content-type
oftext/plain
. result, modern browsers won't interpret javascript, html, or css.they because serving raw files git repo relatively inefficient, want discourage people using github repos static file hosting.
rawgit acts caching proxy, forwarding requests github, caching responses either short time (in case of
rawgit.com
urls) or permanently (in case ofcdn.rawgit.com
urls), , relaying them browser correctcontent-type
headers.
Comments
Post a Comment