Module: VideoHelper

Defined in:
lib/nexmo_developer/app/helpers/video_helper.rb

Instance Method Summary collapse

Instance Method Details



16
17
18
19
# File 'lib/nexmo_developer/app/helpers/video_helper.rb', line 16

def featured_video
  # Any of the latest 3 videos can be "featured"
  Session.where(published: true).order(created_at: 'desc').limit(3).sample
end

#video_embed_url(video_url) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/nexmo_developer/app/helpers/video_helper.rb', line 2

def video_embed_url(video_url)
  if video_url.include? 'youtube'
    video_id = video_url.match(/v=(.{11})/)[1]
    return "https://www.youtube.com/embed/#{video_id}?showinfo=0"
  end

  if video_url.include? 'vimeo'
    video_id = video_url.match(/(\d{7,})/)[1]
    return "https://player.vimeo.com/video/#{video_id}"
  end

  video_url
end