Much base work started
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
Dan Milne
2025-10-31 14:36:14 +11:00
parent 4a35bf6758
commit 88a906064f
97 changed files with 5333 additions and 2774 deletions

View File

@@ -0,0 +1,58 @@
class VideosController < ApplicationController
before_action :set_video, only: [:show, :stream, :playback_position, :retry_processing]
def show
@work = @video.work
@last_position = get_last_playback_position
end
def stream
file_path = @video.web_stream_path
unless file_path && File.exist?(file_path)
head :not_found
return
end
send_file file_path,
filename: @video.filename,
type: 'video/mp4',
disposition: 'inline',
stream: true,
buffer_size: 4096
end
def playback_position
position = params[:position].to_i
session = get_or_create_playback_session
session.update!(position: position, last_played_at: Time.current)
head :ok
end
def retry_processing
VideoProcessorJob.perform_later(@video.id)
redirect_to @video, notice: 'Video processing has been queued.'
end
private
def set_video
@video = Video.find(params[:id])
end
def get_last_playback_position
# Get from current user's session or cookie
session_key = "video_position_#{@video.id}"
session[session_key] || 0
end
def get_or_create_playback_session
# For Phase 1, we'll use a simple session-based approach
# Phase 2 will use proper user authentication
PlaybackSession.find_or_initialize_by(
video: @video,
session_id: session.id.to_s,
user_id: nil # Will be populated in Phase 2
)
end
end