Add super fancy, but super hacky, support for auto-playing videos
This commit is contained in:
parent
b45660f759
commit
3ac599726f
|
@ -5,7 +5,9 @@ module FakeData
|
|||
jobs = []
|
||||
10.times do |i|
|
||||
jobs << {'id' => "cuke-#{i}",
|
||||
'name' => "Cucumber Job #{i}"}
|
||||
'name' => "Cucumber Job #{i}",
|
||||
'end_time' => 30,
|
||||
'start_time' => 20}
|
||||
end
|
||||
jobs
|
||||
end
|
||||
|
|
|
@ -34,18 +34,53 @@ module SauceTV
|
|||
redirect to('/watch')
|
||||
end
|
||||
|
||||
get '/next/after/:id' do |id|
|
||||
unless authenticated?
|
||||
redirect to('/login')
|
||||
end
|
||||
|
||||
api = api_for_session
|
||||
jobs = []
|
||||
begin
|
||||
jobs =api.recent_jobs
|
||||
rescue SauceTV::InvalidUserCredentials
|
||||
redirect to('/login?invalid=true')
|
||||
end
|
||||
|
||||
if jobs.empty?
|
||||
redirect to('/watch')
|
||||
end
|
||||
|
||||
previous = nil
|
||||
jobs.each do |job|
|
||||
break if id == job['id']
|
||||
previous = job
|
||||
end
|
||||
|
||||
unless previous.nil?
|
||||
redirect to("/watch/#{previous['id']}")
|
||||
end
|
||||
redirect to('/watch')
|
||||
end
|
||||
|
||||
get '/watch/:id' do |id|
|
||||
unless authenticated?
|
||||
redirect to('/login')
|
||||
end
|
||||
|
||||
api = api_for_session
|
||||
info = api.info_for(id)
|
||||
begin
|
||||
info = api.info_for(id)
|
||||
rescue SauceTV::InvalidUserCredentials
|
||||
redirect to('/login?invalid=true')
|
||||
end
|
||||
|
||||
haml :player, :locals => {
|
||||
:session => session[:username],
|
||||
:username => session[:username],
|
||||
:id => id,
|
||||
:info => info
|
||||
:delay => info['end_time'] - info['start_time'],
|
||||
:info => info,
|
||||
:token => api.auth_token_for(id)
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
%html
|
||||
%head
|
||||
%meta{'http-equiv' => 'refresh',
|
||||
:content => "#{delay};url=/next/after/#{id}"}
|
||||
%script{:type => 'text/javascript',
|
||||
:src => '/flowplayer/flowplayer-3.2.11.min.js'}
|
||||
%title
|
||||
SauceLabs.tv
|
||||
SauceLabs.tv - #{info['name']}
|
||||
%body
|
||||
Now watching: #{info['name']}
|
||||
Now watching: #{info['name']} (#{delay}s)
|
||||
|
||||
%script{:type => 'text/javascript',
|
||||
:src => "http://saucelabs.com/video-embed/#{id}.js?auth=#{token}"}
|
||||
%script{:type => 'text/javascript'}
|
||||
$f(0).play();
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
%title
|
||||
SauceLabs.tv
|
||||
%body
|
||||
Welcome #{username}
|
||||
|
||||
%div{:style => 'float: right; clear: all; font-weight: bold'}
|
||||
Welcome #{username}
|
||||
|
||||
- unless jobs.empty?
|
||||
%a{:href => "/watch/#{jobs[-1]['id']}"}
|
||||
Auto-Play
|
||||
|
||||
%ul#jobs
|
||||
%ol#jobs
|
||||
- jobs.compact.each do |job|
|
||||
%li.job{:id => "job_#{job['id']}"}
|
||||
%a{:href => "https://saucelabs.com/jobs/#{job['id']}"}
|
||||
%a{:href => "/watch/#{job['id']}"}
|
||||
= job['name']
|
||||
·
|
||||
|
||||
|
|
Loading…
Reference in New Issue