Class: Workarea::Storefront::VideoEmbedder::Vimeo

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/storefront/video_embedder/vimeo.rb

Instance Method Summary collapse

Constructor Details

#initialize(embed_code, options = {}) ⇒ Vimeo



5
6
7
8
# File 'app/services/workarea/storefront/video_embedder/vimeo.rb', line 5

def initialize(embed_code, options = {})
  @embed_code = embed_code
  @options = options
end

Instance Method Details

#attrsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/workarea/storefront/video_embedder/vimeo.rb', line 10

def attrs
  {
    id: vimeo_id,
    src: "#{url}?#{url_params}",
    webkitallowfullscreen: '',
    mozallowfullscreen: '',
    data: {
      vimeo_api: {
        player_id: vimeo_id,
        mute: @options[:mute]
      }.to_json
    }
  }
end

#url_paramsObject



25
26
27
28
29
30
31
32
# File 'app/services/workarea/storefront/video_embedder/vimeo.rb', line 25

def url_params
  parsed_query = Rack::Utils.parse_query(uri.query)
  parsed_query['api'] = 1
  parsed_query['autoplay'] = @options[:autoplay]
  parsed_query['loop'] = @options[:loop_playback]
  parsed_query['player_id'] = vimeo_id
  uri.query = URI.encode_www_form(parsed_query)
end