Class: Dato::Local::FieldType::File::VideoAttributes
- Inherits:
-
Object
- Object
- Dato::Local::FieldType::File::VideoAttributes
- Defined in:
- lib/dato/local/field_type/file.rb
Instance Method Summary collapse
- #duration ⇒ Object
- #frame_rate ⇒ Object
-
#initialize(upload) ⇒ VideoAttributes
constructor
A new instance of VideoAttributes.
- #mp4_url(options = nil) ⇒ Object
- #mux_playback_id ⇒ Object
- #streaming_url ⇒ Object
- #thumbnail_url(format = :jpg) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(upload) ⇒ VideoAttributes
Returns a new instance of VideoAttributes.
141 142 143 |
# File 'lib/dato/local/field_type/file.rb', line 141 def initialize(upload) @upload = upload end |
Instance Method Details
#duration ⇒ Object
153 154 155 |
# File 'lib/dato/local/field_type/file.rb', line 153 def duration @upload.duration end |
#frame_rate ⇒ Object
149 150 151 |
# File 'lib/dato/local/field_type/file.rb', line 149 def frame_rate @upload.frame_rate end |
#mp4_url(options = nil) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/dato/local/field_type/file.rb', line 169 def mp4_url( = nil) @upload.mux_mp4_highest_res or return nil if && [:exact_res] if [:exact_res] == :low raw_mp4_url("low") elsif [:exact_res] == :medium raw_mp4_url("medium") if %w[medium high].include?(@upload.mux_mp4_highest_res) elsif @upload.mux_mp4_highest_res == :high raw_mp4_url("high") end elsif && [:res] == :low raw_mp4_url("low") elsif && [:res] == :medium if %w[low medium].include?(@upload.mux_mp4_highest_res) raw_mp4_url(@upload.mux_mp4_highest_res) else raw_mp4_url("medium") end else raw_mp4_url(@upload.mux_mp4_highest_res) end end |
#mux_playback_id ⇒ Object
145 146 147 |
# File 'lib/dato/local/field_type/file.rb', line 145 def mux_playback_id @upload.mux_playback_id end |
#streaming_url ⇒ Object
157 158 159 |
# File 'lib/dato/local/field_type/file.rb', line 157 def streaming_url "https://stream.mux.com/#{@upload.mux_playback_id}.m3u8" end |
#thumbnail_url(format = :jpg) ⇒ Object
161 162 163 164 165 166 167 |
# File 'lib/dato/local/field_type/file.rb', line 161 def thumbnail_url(format = :jpg) if format == :gif "https://image.mux.com/#{@upload.mux_playback_id}/animated.gif" else "https://image.mux.com/#{@upload.mux_playback_id}/thumbnail.#{format}" end end |
#to_hash ⇒ Object
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/dato/local/field_type/file.rb', line 194 def to_hash { mux_playback_id: mux_playback_id, frame_rate: frame_rate, duration: duration, streaming_url: streaming_url, thumbnail_url: thumbnail_url, mp4_url: mp4_url, } end |