diff --git a/assets/audio/africa.m4a b/assets/audio/africa.m4a index cee85ba..90d8417 100644 Binary files a/assets/audio/africa.m4a and b/assets/audio/africa.m4a differ diff --git a/assets/audio/africa.mp3 b/assets/audio/africa.mp3 deleted file mode 100644 index 7f45e50..0000000 Binary files a/assets/audio/africa.mp3 and /dev/null differ diff --git a/assets/audio/africa.ogg b/assets/audio/africa.ogg index 2a995ab..0768787 100644 Binary files a/assets/audio/africa.ogg and b/assets/audio/africa.ogg differ diff --git a/assets/scripts/africa.js b/assets/scripts/africa.js index 08ffedf..74b5c55 100644 --- a/assets/scripts/africa.js +++ b/assets/scripts/africa.js @@ -1,63 +1,42 @@ -$(document).ready(function() { - if(isMobile.any()) { - showButton("Play"); +var playing = false; +var control = document.getElementById('control'); +var background = document.getElementById('background'); + +var sound = new Howl({ + urls: ['assets/audio/africa.ogg', 'assets/audio/africa.m4a'], + autoplay: true, + loop: true +}); + +function toggle() { + if(playing) { + sound.pause(); + playing = false; + control.className = 'icon-play'; } else { - showButton("None"); + sound.play(); + playing = true; + control.className = 'icon-pause'; } +} - var mediaPlayer = jQuery('#player'); +function load() { + makeItRain(); + if(!isMobile.any()) { + playing = true; + control.style.visibility = 'hidden'; + } +} - mediaPlayer.jPlayer({ - solution: "html", - supplied : 'mp3, oga, m4a', - cssSelector: { - play: '#play', - }, - - ready: function() {jQuery(this).jPlayer("setMedia", { - mp3: 'assets/audio/africa.mp3', - oga: 'assets/audio/africa.oga', - m4a: 'assets/audio/africa.m4a' - }).jPlayer("play");}, - - loop: true - }); - - $('#play').click(function() { - if(isMobile.any()) { - showButton("Pause"); - } - $('#player').jPlayer('play'); - }); - - $('#pause').click(function() { - if(isMobile.any()) { - showButton("Play"); - } - $('#player').jPlayer('pause'); - }); - - var image = document.getElementById('background'); - image.onload = function() { +function makeItRain() { + background.onload = function() { var engine = new RainyDay({ image: this }); engine.rain([ [3, 2, 2] ], 100); }; - image.crossOrigin = 'anonymous'; -}); - -function showButton(mode) { - if(mode === "Play") { - $('#play').show(); - $('#pause').hide(); - } else if(mode == "Pause") { - $('#play').hide(); - $('#pause').show(); - } else { - $('#play').hide(); - $('#pause').hide(); - } + background.src = 'assets/images/africa.png'; + background.crossOrigin = 'anonymous'; } var isMobile = { @@ -68,3 +47,4 @@ var isMobile = { Windows: function() { return navigator.userAgent.match(/IEMobile/i); }, any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } }; + diff --git a/assets/styles/style.css b/assets/styles/style.css index b5e3f95..0f9bafd 100644 --- a/assets/styles/style.css +++ b/assets/styles/style.css @@ -9,17 +9,17 @@ html, body, img, #container { position: absolute; left: 0px; top: 0px; + z-index: 500; + text-align: center; } -.button { +#control { display: inline-block; - padding: 10px; border-radius: 10px; position: relative; - top: 50%; -webkit-transform: translateY(50%); -ms-transform: translateY(50%); transform: translateY(50%); @@ -27,5 +27,4 @@ html, body, img, #container { background: rgba(0, 0, 0, .5); color: white; font-size: 40vw; - text-align: center; } diff --git a/index.html b/index.html index d919bae..4442e49 100644 --- a/index.html +++ b/index.html @@ -8,19 +8,17 @@ - - - - -
- + +