1
0
Fork 0

New html5 player

This commit is contained in:
magnolia-fan 2011-04-10 22:04:35 +04:00
parent a738e533c1
commit b5e2563bf9
14 changed files with 200 additions and 482 deletions

View File

@ -17,7 +17,7 @@
<ul class="tracks">
<% first_release.tracks.each do |track| %>
<li id="<%= track.id %>">
<span class="play<%= (track.inDb ? '' : ' disabled') %>"></span>
<span class="play<%= (track.inDb ? '' : ' disabled') %>"><img src="/images/player/play.svg" alt="play" /></span>
<span class="track-name"><%= track.name %></span>
<span class="duration"><%= track.length.toTime %></span>
</li>

View File

@ -10,10 +10,21 @@
<div id="contents">
<div class="inner-1">
<div id="player">
<span id="artist"></span>
<span id="dash"> - </span>
<span id="title"></span>
<audio controls preload autoplay style="width:1000px;"></audio>
<audio></audio>
<div class="prev"><img src="/images/player/prev.svg" alt="prev" /></div>
<div class="play"><img src="/images/player/play.svg" alt="play" /></div>
<div class="pause" style="display:none"><img src="/images/player/pause.svg" alt="pause" /></div>
<div class="next"><img src="/images/player/next.svg" alt="pause" /></div>
<div class="time-played">0:00</div>
<div class="progress">
<div class="track-title">No track</div>
<div class="progress-bar">
<div class="progress-loaded">
<div class="progress-point"></div>
</div>
</div>
</div>
<div class="time-left">0:00</div>
</div>
<%= yield %>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 KiB

View File

@ -0,0 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1000" height="1000" version="1.1" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,250 500,500 0,750" style="fill:rgb(200,200,200);"/>
<polygon points="500,250 1000,500 500,750" style="fill:rgb(200,200,200);"/>
</svg>

After

Width:  |  Height:  |  Size: 374 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1000" height="1000" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="50" width="400" height="1000" style="fill:rgb(200,200,200);"/>
<rect x="600" width="400" height="1000" style="fill:rgb(200,200,200);"/>
</svg>

After

Width:  |  Height:  |  Size: 372 B

View File

@ -0,0 +1,5 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1000" height="1000" version="1.1" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,0 1000,500 0,1000" style="fill:rgb(200,200,200);"/>
</svg>

After

Width:  |  Height:  |  Size: 297 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1000" height="1000" version="1.1" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,500 500,250 500,750" style="fill:rgb(200,200,200);"/>
<polygon points="500,500 1000,250 1000,750" style="fill:rgb(200,200,200);"/>
</svg>

After

Width:  |  Height:  |  Size: 377 B

View File

@ -1,8 +1,50 @@
var audio;
var utid;
$(function(){
$('.play').click(function(){
$('#player audio').attr('src', '/listen/'+ $(this).parent().attr('id')) +'/';
$('#player #artist').html($('h1.artist').html());
$('#player #title').html($(this).parent().find('.track-name').html());
$('#player audio').play();
audio = document.getElementsByTagName('audio')[0];
$('#player .play').click(function(){
audio.play();
utid = window.setTimeout(updatePlayer, 100);
$('#player .pause').show();
$('#player .play').hide();
})
})
$('#player .pause').click(function(){
audio.pause();
clearTimeout(utid);
$('#player .pause').hide();
$('#player .play').show();
})
$('.tracks .play').click(function(){
playTrack($('h1.artist').html(), $(this).parent().find('.track-name').html(), '/listen/'+ $(this).parent().attr('id') +'/');
})
})
function updatePlayer() {
duration = audio.duration;
cur_time = audio.currentTime;
loaded = 0;
if ((audio.buffered != undefined) && (audio.buffered.length != 0)) {
loaded = Math.round((audio.buffered.end(0) / audio.duration) * 730);
}
$('#player .time-played').html(formatTime(cur_time));
$('#player .time-left').html(formatTime(duration - cur_time));
progress = Math.round((cur_time / duration) * 730);
$('#player .progress-loaded').css('width', loaded +'px')
$('#player .progress-point').css('margin-left', progress +'px')
utid = window.setTimeout(updatePlayer, 100);
}
function formatTime(sec) {
sec = Math.round(sec);
m = Math.floor(sec / 60);
s = sec - (m * 60);
return m +':'+ (s < 10 ? '0' : '') +s;
}
function playTrack(artist, track, stream) {
$(audio).attr('src', stream);
$('#player .track-title').html(artist +' &mdash; '+ track);
$('#player .time-played').html('0:00');
$('#player .time-left').html('0:00');
$('#player .progress-loaded').css('width', 0 +'px')
$('#player .progress-point').css('margin-left', 0 +'px')
$('#player .play').trigger('click');
}

View File

@ -60,6 +60,7 @@ body {
float: left;
width: 100%;
line-height: 30px;
margin: 0 0 0.2em 0;
}
.album .tracks li .duration {
@ -68,40 +69,27 @@ body {
float: right;
}
.album .tracks li .play {
.album .tracks li .play {
display: block;
float: left;
background-image: url(/images/play.png);
width: 31px;
width: 30px;
height: 30px;
border-radius: 30px;
background-color: #05A;
margin: 0 0.3em 0 0;
cursor: pointer;
}
.album .tracks li .play img {
width: 12px;
height: 12px;
margin: 9px 0 0 10px;
}
.album .tracks li .play.disabled {
background-image: none;
background-color: #CDF;
}
#player {
position: fixed;
top: 0;
left: 50%;
margin-left: -500px;
width: 1000px;
height: 111px;
background-color: #333;
border: #222 1px solid;
}
#artist, #dash, #title {
line-height: 87px;
font-size: 2em;
color: #AAA;
}
#dash {
color: #666;
}
.search {
width: 100%;

View File

@ -1,448 +0,0 @@
/*
* Skin for jPlayer Plugin (jQuery JavaScript Library)
* http://www.happyworm.com/jquery/jplayer
*
* Skin Name: Blue Monday
*
* Copyright (c) 2010 Happyworm Ltd
* Dual licensed under the MIT and GPL licenses.
* - http://www.opensource.org/licenses/mit-license.php
* - http://www.gnu.org/copyleft/gpl.html
*
* Author: Silvia Benvenuti
* Skin Version: 3.0 (jPlayer 2.0.0)
* Date: 20th December 2010
*/
div.jp-audio,
div.jp-video {
/* Edit the font-size to counteract inherited font sizing.
* Eg. 1.25em = 1 / 0.8em
*/
font-size:1.25em;
font-family:Verdana, Arial, sans-serif;
line-height:1.6;
color: #666;
}
div.jp-audio {
width:1000px;
}
div.jp-video-270p {
width:480px;
}
div.jp-video-360p {
width:640px;
}
div.jp-interface {
position: relative;
background-color:#eee;
/* width:418px; */
width:100%;
/* border:1px solid #009be3;*/
}
div.jp-audio div.jp-type-single div.jp-interface {
height:80px;
border-bottom:none;
}
div.jp-audio div.jp-type-playlist div.jp-interface {
height:80px;
}
div.jp-video div.jp-type-single div.jp-interface {
height:60px;
border-bottom:none;
}
div.jp-video div.jp-type-playlist div.jp-interface {
height:60px;
}
div.jp-interface ul.jp-controls {
list-style-type:none;
padding:0;
margin: 0;
}
div.jp-interface ul.jp-controls li {
/* position: absolute; */
display:inline;
}
div.jp-interface ul.jp-controls a {
position: absolute;
overflow:hidden;
text-indent:-9999px;
}
a.jp-play,
a.jp-pause {
width:40px;
height:40px;
z-index:1;
}
div.jp-audio div.jp-type-single a.jp-play,
div.jp-audio div.jp-type-single a.jp-pause {
top:20px;
left:40px;
}
div.jp-audio div.jp-type-playlist a.jp-play,
div.jp-audio div.jp-type-playlist a.jp-pause {
top:20px;
left:48px;
}
div.jp-video a.jp-play,
div.jp-video a.jp-pause {
top:15px;
}
div.jp-video-270p div.jp-type-single a.jp-play,
div.jp-video-270p div.jp-type-single a.jp-pause {
left:195px;
}
div.jp-video-270p div.jp-type-playlist a.jp-play,
div.jp-video-270p div.jp-type-playlist a.jp-pause {
left:220px;
}
div.jp-video-360p div.jp-type-single a.jp-play,
div.jp-video-360p div.jp-type-single a.jp-pause {
left:275px;
}
div.jp-video-360p div.jp-type-playlist a.jp-play,
div.jp-video-360p div.jp-type-playlist a.jp-pause {
left:300px;
}
a.jp-play {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 0 no-repeat;
}
a.jp-play:hover {
background: url("../images/jplayer/jplayer.blue.monday.jpg") -41px 0 no-repeat;
}
a.jp-pause {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -42px no-repeat;
display: none;
}
a.jp-pause:hover {
background: url("../images/jplayer/jplayer.blue.monday.jpg") -41px -42px no-repeat;
}
div.jp-audio div.jp-type-single a.jp-stop {
top:26px;
left:90px;
}
div.jp-audio div.jp-type-playlist a.jp-stop {
top:26px;
left:126px;
}
div.jp-video a.jp-stop {
top:21px;
}
div.jp-video-270p div.jp-type-single a.jp-stop {
left:245px;
}
div.jp-video-270p div.jp-type-playlist a.jp-stop {
left:298px;
}
div.jp-video-360p div.jp-type-single a.jp-stop {
left:325px;
}
div.jp-video-360p div.jp-type-playlist a.jp-stop {
left:378px;
}
a.jp-stop {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -83px no-repeat;
width:28px;
height:28px;
z-index:1;
}
a.jp-stop:hover {
background: url("../images/jplayer/jplayer.blue.monday.jpg") -29px -83px no-repeat;
}
div.jp-audio div.jp-type-playlist a.jp-previous {
left:20px;
top:26px;
}
div.jp-video div.jp-type-playlist a.jp-previous {
top:21px;
}
div.jp-video-270p div.jp-type-playlist a.jp-previous {
left:192px;
}
div.jp-video-360p div.jp-type-playlist a.jp-previous {
left:272px;
}
a.jp-previous {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -112px no-repeat;
width:28px;
height:28px;
}
a.jp-previous:hover {
background: url("../images/jplayer/jplayer.blue.monday.jpg") -29px -112px no-repeat;
}
div.jp-audio div.jp-type-playlist a.jp-next {
left:88px;
top:26px;
}
div.jp-video div.jp-type-playlist a.jp-next {
top:21px;
}
div.jp-video-270p div.jp-type-playlist a.jp-next {
left:260px;
}
div.jp-video-360p div.jp-type-playlist a.jp-next {
left:340px;
}
a.jp-next {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -141px no-repeat;
width:28px;
height:28px;
}
a.jp-next:hover {
background: url("../images/jplayer/jplayer.blue.monday.jpg") -29px -141px no-repeat;
}
div.jp-progress {
position: absolute;
overflow:hidden;
background-color: #ddd;
}
div.jp-audio div.jp-type-single div.jp-progress {
top:32px;
left:130px;
width:122px;
height:15px;
}
div.jp-audio div.jp-type-playlist div.jp-progress {
top:32px;
left:164px;
width:122px;
height:15px;
}
div.jp-video div.jp-progress {
top:0px;
left:0px;
width:100%;
height:10px;
}
div.jp-seek-bar {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -202px repeat-x;
width:0px;
/* height:15px; */
height:100%;
cursor: pointer;
}
div.jp-play-bar {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -218px repeat-x ;
width:0px;
/* height:15px; */
height:100%;
}
/* The seeking class is added/removed inside jPlayer */
div.jp-seeking-bg {
background: url("pbar-ani.gif");
}
a.jp-mute,
a.jp-unmute {
width:18px;
height:15px;
}
div.jp-audio div.jp-type-single a.jp-mute,
div.jp-audio div.jp-type-single a.jp-unmute {
top:32px;
left:274px;
}
div.jp-audio div.jp-type-playlist a.jp-mute,
div.jp-audio div.jp-type-playlist a.jp-unmute {
top:32px;
left:296px;
}
div.jp-video a.jp-mute,
div.jp-video a.jp-unmute {
top:27px;
}
div.jp-video-270p div.jp-type-single a.jp-mute,
div.jp-video-270p div.jp-type-single a.jp-unmute {
left:304px;
}
div.jp-video-270p div.jp-type-playlist a.jp-unmute,
div.jp-video-270p div.jp-type-playlist a.jp-mute {
left:363px;
}
div.jp-video-360p div.jp-type-single a.jp-mute,
div.jp-video-360p div.jp-type-single a.jp-unmute {
left:384px;
}
div.jp-video-360p div.jp-type-playlist a.jp-mute,
div.jp-video-360p div.jp-type-playlist a.jp-unmute {
left:443px;
}
a.jp-mute {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -186px no-repeat;
}
a.jp-mute:hover {
background: url("../images/jplayer/jplayer.blue.monday.jpg") -19px -170px no-repeat;
}
a.jp-unmute {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -170px no-repeat;
display: none;
}
a.jp-unmute:hover {
background: url("../images/jplayer/jplayer.blue.monday.jpg") -19px -186px no-repeat;
}
div.jp-volume-bar {
position: absolute;
overflow:hidden;
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -250px repeat-x;
width:46px;
height:5px;
cursor: pointer;
}
div.jp-audio div.jp-type-single div.jp-volume-bar {
top:37px;
left:302px;
}
div.jp-audio div.jp-type-playlist div.jp-volume-bar {
top:37px;
left:324px;
}
div.jp-video div.jp-volume-bar {
top:32px;
}
div.jp-video-270p div.jp-type-single div.jp-volume-bar {
left:332px;
}
div.jp-video-270p div.jp-type-playlist div.jp-volume-bar {
left:391px;
}
div.jp-video-360p div.jp-type-single div.jp-volume-bar {
left:412px;
}
div.jp-video-360p div.jp-type-playlist div.jp-volume-bar {
left:471px;
}
div.jp-volume-bar-value {
background: url("../images/jplayer/jplayer.blue.monday.jpg") 0 -256px repeat-x;
width:0px;
height:5px;
}
div.jp-current-time,
div.jp-duration {
position: absolute;
font-size:.64em;
font-style:oblique;
}
div.jp-duration {
text-align: right;
}
div.jp-audio div.jp-type-single div.jp-current-time,
div.jp-audio div.jp-type-single div.jp-duration {
top:49px;
left:130px;
width:122px;
}
div.jp-audio div.jp-type-playlist div.jp-current-time,
div.jp-audio div.jp-type-playlist div.jp-duration {
top:49px;
left:164px;
width:122px;
}
div.jp-video div.jp-current-time,
div.jp-video div.jp-duration {
top:10px;
left:0px;
width:98%;
padding:0 1%;
}
div.jp-playlist {
/* width:418px; */
width:100%;
background-color:#ccc;
/* border:1px solid #009be3;*/
border-top:none;
}
div.jp-playlist ul {
list-style-type:none;
margin:0;
padding:0 20px;
/* background-color:#ccc; */
/* border:1px solid #009be3; */
/* border-top:none; */
/* width:378px; */
font-size:.72em;
}
div.jp-type-single div.jp-playlist li {
padding:5px 0 5px 20px;
font-weight:bold;
}
div.jp-type-playlist div.jp-playlist li {
padding:5px 0 4px 20px;
border-bottom:1px solid #eee;
}
/*
div.jp-video div.jp-playlist li {
padding:5px 0 5px 20px;
font-weight:bold;
}
*/
div.jp-type-playlist div.jp-playlist li.jp-playlist-last {
padding:5px 0 5px 20px;
border-bottom:none;
}
div.jp-type-playlist div.jp-playlist li.jp-playlist-current {
list-style-type:square;
list-style-position:inside;
padding-left:8px;
}
div.jp-type-playlist div.jp-playlist a {
color: #666;
text-decoration: none;
}
div.jp-type-playlist div.jp-playlist a:hover {
color:#0d88c1;
}
div.jp-type-playlist div.jp-playlist a.jp-playlist-current {
color:#0d88c1;
}
div.jp-type-playlist div.jp-playlist div.jp-free-media {
display:inline;
margin-left:20px;
}
div.jp-video div.jp-video-play {
background: transparent url("../images/jplayer/jplayer.blue.monday.video.play.png") no-repeat center;
/* position: relative; */
position: absolute;
cursor:pointer;
z-index:2;
}
div.jp-video div.jp-video-play:hover {
background: transparent url("../images/jplayer/jplayer.blue.monday.video.play.hover.png") no-repeat center;
}
div.jp-video-270p div.jp-video-play {
top:-270px;
width:480px;
height:270px;
}
div.jp-video-360p div.jp-video-play {
top:-360px;
width:640px;
height:360px;
}
div.jp-jplayer {
width:0px;
height:0px;
}
div.jp-video div.jp-jplayer {
/* border:1px solid #009be3;*/
border-bottom:none;
z-index:1;
}
div.jp-video-270p div.jp-jplayer {
width:480px;
height:270px;
}
div.jp-video-360p div.jp-jplayer {
width:640px;
height:360px;
}
div.jp-jplayer {
background-color: #000000;
}

View File

@ -0,0 +1,102 @@
#player {
position: fixed;
width: 1000px;
height: 50px;
left: 50%;
top: 0;
margin-left: -500px;
background-color: #000;
font-size: 12px;
}
#player .prev, #player .next, #player .play, #player .pause {
float: left;
color: #AAA;
background-color: #222;
cursor: pointer;
}
#player .prev, #player .next {
width: 30px;
height: 30px;
margin: 10px 0;
border-radius: 40px;
}
#player .prev img, #player .next img {
width: 14px;
height: 14px;
}
#player .prev img {
margin: 8px 0 0 7px;
}
#player .next img {
margin: 8px 0 0 9px;
}
#player .play, #player .pause {
width: 40px;
height: 40px;
margin: 5px;
border-radius: 40px;
}
#player .play img {
width: 16px;
height: 16px;
margin: 12px 0 0 14px;
}
#player .pause img {
width: 16px;
height: 16px;
margin: 12px 0 0 12px;
}
#player .prev {
margin-left: 20px;
}
#player .next {
margin-right: 20px;
}
#player .time-played, #player .time-left {
float: left;
height: 50px;
width: 50px;
color: #AAA;
margin-right: 2px;
text-align: center;
line-height: 50px;
}
#player .progress {
float: left;
margin-top: 25px;
height: 25px;
width: 740px;
}
#player .track-title {
float: left;
width: 730px;
height: 25px;
margin-left: 5px;
margin-top: -25px;
color: #DDD;
line-height: 30px;
}
#player .progress-bar {
float: left;
margin: 11px 5px;
background-color: #013;
width: 730px;
height: 3px;
}
#player .progress-loaded {
float: left;
width: 0;
height: 3px;
background-color: #05A;
}
#player .progress-point {
float: left;
width: 6px;
height: 6px;
background-color: #013;
margin-top: -4px;
margin-left: 0;
border: #FFF 3px solid;
border-radius: 6px;
cursor: pointer;
}