Skip to content

Commit 0e2e531

Browse files
committed
added type option to video component in order to support more than mp4
1 parent f14034d commit 0e2e531

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
%video{@tag_attributes}
2-
%source{:src => @source, :type => "video/mp4"}
2+
%source{:src => @source, :type => @type}
33
Your browser does not support the video tag.

app/concepts/matestack/ui/core/video/video.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Matestack::Ui::Core::Video
22
class Video < Matestack::Ui::Core::Component::Static
33

4-
REQUIRED_KEYS = [:path]
4+
REQUIRED_KEYS = [:path, :type]
55

66
def setup
77
@tag_attributes.merge!({
@@ -16,6 +16,7 @@ def setup
1616
})
1717

1818
@source = ActionController::Base.helpers.asset_path(options[:path])
19+
@type = "video/#{@options[:type]}"
1920
end
2021

2122
end

docs/components/video.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Show [specs](/spec/usage/components/video_spec.rb)
44

5-
The HTML video tag implemented in Ruby. Right now, only the MP4 format is supported.
5+
The HTML video tag implemented in Ruby.
66

77
## Parameters
8-
The video component takes a mandatory path argument and can take a number of optional configuration params.
8+
The video component takes mandatory path and type arguments and can take a number of optional configuration params.
99

1010
#### # autoplay (optional)
1111
Expects a boolean and specifies whether the video should start playing as soon as it is ready.
@@ -28,6 +28,9 @@ Expects a boolean and specifies whether the audio output of the video should be
2828
#### # path
2929
Expects a string with the source to the video. It looks for the video in the `assets/videos` folder and uses the standard Rails asset pipeline.
3030

31+
#### # type
32+
Expects a string with the type to the video.
33+
3134
#### # playsinline (optional)
3235
Expects a boolean and specifies whether the video should be played inline on iOS Safari.
3336

@@ -41,7 +44,7 @@ Expects an integer with the width of the video in px.
4144

4245

4346
```ruby
44-
video path: 'corgi.mp4', width: 500, height: 300
47+
video path: 'corgi.mp4', type: "mp4", width: 500, height: 300
4548
```
4649

4750
returns

spec/usage/components/video_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class ExamplePage < Matestack::Ui::Page
88
def response
99
components {
10-
video path: 'corgi.mp4', width: 500, height: 300
10+
video path: 'corgi.mp4', type: "mp4", width: 500, height: 300
1111
}
1212
end
1313
end
@@ -22,7 +22,7 @@ def response
2222
class ExamplePage < Matestack::Ui::Page
2323
def response
2424
components {
25-
video path: 'corgi.mp4', width: 500, height: 300, autoplay: true, controls: true, loop: true, muted: true, playsinline: false, preload: 'auto'
25+
video path: 'corgi.mp4', type: "mp4", width: 500, height: 300, autoplay: true, controls: true, loop: true, muted: true, playsinline: false, preload: 'auto'
2626
}
2727
end
2828
end

0 commit comments

Comments
 (0)