From 42f3e6e5ca57c4387d2dd6267dc442142fb4dba9 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Mon, 11 Apr 2011 20:49:25 +0400 Subject: [PATCH] Player & duration fix 1 --- app/controllers/track_controller.rb | 1 + app/views/artist/view.rhtml | 4 +++- app/views/layouts/application.html.erb | 2 +- nginx/proxy.conf | 6 +++--- public/javascripts/player.js | 4 ++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 8586340..da74a75 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -14,6 +14,7 @@ class TrackController < ApplicationController #render :inline => nginx_url headers['Content-Type'] = 'audio/mpeg' headers['X-Accel-Redirect'] = nginx_url + headers['Connection'] = 'close' render :nothing => true end end diff --git a/app/views/artist/view.rhtml b/app/views/artist/view.rhtml index 39757bc..0e8b8ad 100644 --- a/app/views/artist/view.rhtml +++ b/app/views/artist/view.rhtml @@ -19,7 +19,9 @@
  • play <%= track.name %> - <%= track.length.toTime %> + <% unless track.length.nil? %> + <%= track.length.toTime %> + <% end %>
  • <% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 13105c0..c9c9f85 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,7 +12,7 @@
    - +
    play
    diff --git a/nginx/proxy.conf b/nginx/proxy.conf index ec6820c..47949d8 100644 --- a/nginx/proxy.conf +++ b/nginx/proxy.conf @@ -30,9 +30,9 @@ location ~* ^/proxy-stream/(.*?)/(.*?)/(.*?)/(.*?)/(.*) { # backend does not support Content-Disposition # headers used to specify file name browsers use # when save content to the disk - proxy_hide_header Content-Type; - proxy_hide_header Content-Disposition; - add_header Content-Disposition 'attachment; filename=audio.mp3'; + proxy_ignore_headers Cache-Control; + #add_header Content-Disposition 'attachment; filename=audio.mp3'; + #add_header Connection 'close'; # Do not touch local disks when proxying # content to clients diff --git a/public/javascripts/player.js b/public/javascripts/player.js index 07c82c4..df82813 100644 --- a/public/javascripts/player.js +++ b/public/javascripts/player.js @@ -52,7 +52,7 @@ function formatTime(sec) { return m +':'+ (s < 10 ? '0' : '') +s; } function playTrack(artist, track, id) { - $(audio).attr('src', '/listen/'+ id +'/'); + $(audio).attr('src', '/listen/'+ id +'.mp3'); $('#player .track-title').html(artist +' — '+ track); $('#player .time-played').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) { playTrack(artist, track, id); } -} \ No newline at end of file +}