1
0
Fork 0

Seamless looping minus jquery

This commit is contained in:
Andrew Tomaka 2014-09-25 13:28:27 -04:00
parent 7b773ece82
commit 8347a95867
6 changed files with 41 additions and 64 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -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()); }
};

View file

@ -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;
}

View file

@ -8,19 +8,17 @@
<![endif]-->
<link rel="stylesheet" href="assets/styles/style.css" type="text/css" />
<link rel="stylesheet" href="assets/styles/font.css" type="text/css" />
<script src="assets/scripts/rainyday.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jplayer/2.7.1/jquery.jplayer/jquery.jplayer.js"></script>
<script src="assets/scripts/africa.js"></script>
</head>
<body>
<img id="background" src="assets/images/africa.png" />
<body onload="javascript:load()";>
<img id="background" src="" />
<div id="container">
<div id="player"></div>
<div id="play" class="button"><i class="icon-play"></i></div>
<div id="pause" class="button"><i class="icon-pause"></i></div>
<i id="control" class="icon-pause" onclick="javascript:toggle();"></i>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/howler/1.1.17/howler.min.js"></script>
<script src="assets/scripts/rainyday.js"></script>
<script src="assets/scripts/africa.js"></script>
</body>
</html>