1
0
Fork 0

Player & duration fix 1

This commit is contained in:
magnolia-fan 2011-04-11 20:49:25 +04:00
parent 4d2c32ec8e
commit 42f3e6e5ca
5 changed files with 10 additions and 7 deletions

View File

@ -14,6 +14,7 @@ class TrackController < ApplicationController
#render :inline => nginx_url #render :inline => nginx_url
headers['Content-Type'] = 'audio/mpeg' headers['Content-Type'] = 'audio/mpeg'
headers['X-Accel-Redirect'] = nginx_url headers['X-Accel-Redirect'] = nginx_url
headers['Connection'] = 'close'
render :nothing => true render :nothing => true
end end
end end

View File

@ -19,7 +19,9 @@
<li id="<%= track.id %>"> <li id="<%= track.id %>">
<span class="play<%= (track.inDb ? '' : ' disabled') %>"><img src="/images/player/play.svg" alt="play" /></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="track-name"><%= track.name %></span>
<span class="duration" data-length="<%= track.length %>"><%= track.length.toTime %></span> <% unless track.length.nil? %>
<span class="duration" data-length="<%= track.length %>"><%= track.length.toTime %></span>
<% end %>
</li> </li>
<% end %> <% end %>
</ul> </ul>

View File

@ -12,7 +12,7 @@
<div id="contents"> <div id="contents">
<div class="inner-1"> <div class="inner-1">
<div id="player"> <div id="player">
<audio></audio> <audio autoplay preload></audio>
<div class="prev"><img src="/images/player/prev.svg" alt="prev" /></div> <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="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="pause" style="display:none"><img src="/images/player/pause.svg" alt="pause" /></div>

View File

@ -30,9 +30,9 @@ location ~* ^/proxy-stream/(.*?)/(.*?)/(.*?)/(.*?)/(.*) {
# backend does not support Content-Disposition # backend does not support Content-Disposition
# headers used to specify file name browsers use # headers used to specify file name browsers use
# when save content to the disk # when save content to the disk
proxy_hide_header Content-Type; proxy_ignore_headers Cache-Control;
proxy_hide_header Content-Disposition; #add_header Content-Disposition 'attachment; filename=audio.mp3';
add_header Content-Disposition 'attachment; filename=audio.mp3'; #add_header Connection 'close';
# Do not touch local disks when proxying # Do not touch local disks when proxying
# content to clients # content to clients

View File

@ -52,7 +52,7 @@ function formatTime(sec) {
return m +':'+ (s < 10 ? '0' : '') +s; return m +':'+ (s < 10 ? '0' : '') +s;
} }
function playTrack(artist, track, id) { function playTrack(artist, track, id) {
$(audio).attr('src', '/listen/'+ id +'/'); $(audio).attr('src', '/listen/'+ id +'.mp3');
$('#player .track-title').html(artist +' &mdash; '+ track); $('#player .track-title').html(artist +' &mdash; '+ track);
$('#player .time-played').html('0:00'); $('#player .time-played').html('0:00');
$('#player .time-left').html('0:00'); $('#player .time-left').html('0:00');
@ -79,4 +79,4 @@ function addToPlaylist(artist, track, length, id) {
if ($('#playlist ul li').length == 1) { if ($('#playlist ul li').length == 1) {
playTrack(artist, track, id); playTrack(artist, track, id);
} }
} }