Question

I want to check if the request from is browser then expose the video cdn link to jwplayer. I want to make hard video from download.

My routes code is

 4   match "/assets/protect/:id.:format" => "streams#show"

My controller code is

  1 class StreamsController < ApplicationController
  2   def show
  3     self.response.headers["Location"] = Video.find(params[:id]).video.url.safe # here is the    condition if request is from browser
  4     render nothing: true, layout: false
  5   end
  6 end

My JS code

  2     jwplayer("video-player-container").setup({
  3       file: "/assets/protect/<%= @video.id %>.flv",
  4       wmode: 'transparent',
  5       flashplayer: "/jwplayer/player.swf",
  6       players: [{ type: "flash", src: "/jwplayer/player.swf" }, { type: "html5" }]
  7     });

is this possible or any other alternate solution?

regards

V

Was it helpful?

Solution

def show
  send_data Video.find(params[:id]).video.url.safe_url, type: "video/mp4", :disposition=>'inline'
end

Try this!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top