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 = []
|
jobs = []
|
||||||
10.times do |i|
|
10.times do |i|
|
||||||
jobs << {'id' => "cuke-#{i}",
|
jobs << {'id' => "cuke-#{i}",
|
||||||
'name' => "Cucumber Job #{i}"}
|
'name' => "Cucumber Job #{i}",
|
||||||
|
'end_time' => 30,
|
||||||
|
'start_time' => 20}
|
||||||
end
|
end
|
||||||
jobs
|
jobs
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,18 +34,53 @@ module SauceTV
|
||||||
redirect to('/watch')
|
redirect to('/watch')
|
||||||
end
|
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|
|
get '/watch/:id' do |id|
|
||||||
unless authenticated?
|
unless authenticated?
|
||||||
redirect to('/login')
|
redirect to('/login')
|
||||||
end
|
end
|
||||||
|
|
||||||
api = api_for_session
|
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 => {
|
haml :player, :locals => {
|
||||||
:session => session[:username],
|
:username => session[:username],
|
||||||
:id => id,
|
:id => id,
|
||||||
:info => info
|
:delay => info['end_time'] - info['start_time'],
|
||||||
|
:info => info,
|
||||||
|
:token => api.auth_token_for(id)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
%html
|
%html
|
||||||
%head
|
%head
|
||||||
|
%meta{'http-equiv' => 'refresh',
|
||||||
|
:content => "#{delay};url=/next/after/#{id}"}
|
||||||
|
%script{:type => 'text/javascript',
|
||||||
|
:src => '/flowplayer/flowplayer-3.2.11.min.js'}
|
||||||
%title
|
%title
|
||||||
SauceLabs.tv
|
SauceLabs.tv - #{info['name']}
|
||||||
%body
|
%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
|
%title
|
||||||
SauceLabs.tv
|
SauceLabs.tv
|
||||||
%body
|
%body
|
||||||
Welcome #{username}
|
%div{:style => 'float: right; clear: all; font-weight: bold'}
|
||||||
|
Welcome #{username}
|
||||||
|
|
||||||
- unless jobs.empty?
|
- unless jobs.empty?
|
||||||
%a{:href => "/watch/#{jobs[-1]['id']}"}
|
%a{:href => "/watch/#{jobs[-1]['id']}"}
|
||||||
Auto-Play
|
Auto-Play
|
||||||
|
|
||||||
%ul#jobs
|
%ol#jobs
|
||||||
- jobs.compact.each do |job|
|
- jobs.compact.each do |job|
|
||||||
%li.job{:id => "job_#{job['id']}"}
|
%li.job{:id => "job_#{job['id']}"}
|
||||||
%a{:href => "https://saucelabs.com/jobs/#{job['id']}"}
|
%a{:href => "/watch/#{job['id']}"}
|
||||||
= job['name']
|
= job['name']
|
||||||
·
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue