Ruby on Rails Friday, September 30, 2011

On Sep 30, 2011, at 4:06 PM, Garrett S. wrote:

> I'm writing a Ruby on Rails application which allows a user to upload an
> mp3 file, then play it back. I have it working to the point where a user
> can do those things, BUT there is an issue when seeking through the
> song. If a user seeks ahead (or lets it play) to a spot in the song,
> usually about 2/3 or 3/4 the way through the song, then attempts to seek
> back to the beginning (for example 0:20), the play timer will go to
> 0:20, like it should but the actual audio will start over again as if
> the user seeked to 0:00.
>
> Right now I'm simply attempting to get the song to play in chrome's
> basic html5 mp3 player that it uses when passed an mp3 file. This is the
> code I'm using to serve up the file, hopefully with all the correct
> headers:
>
> http://privatepaste.com/8406f69836
>
> I think it has something to do with send_file not accepting the range
> header, maybe it's just the way I'm setting it? I'd appreciate any
> insight into this problem. I feel like I'm so close because it pretty
> much all works, except for seeking near the beginning causing a new
> request.

Can you just pass the URL to the file, and not pass it through send_file? I've used

def download
if cannot?( :download, Title )
raise CanCan::AccessDenied
else
redirect_to @asset.source.expiring_url(10)
end
end

from Paperclip to handle a link to a protected file on S3. Works like a charm, and it's just a file download from S3, so it's up to the browser to handle that.

Walter

>
> Thanks!
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment