Class: Dommy::HTMLMediaElement

Inherits:
HTMLElement show all
Defined in:
lib/dommy/html_elements.rb

Overview

‘<audio>` / `<video>` shared base. The actual media engine is absent in Dommy — getters return inert values, `play()` returns a resolved Promise, and `pause()` flips `paused` back to true.

Direct Known Subclasses

HTMLAudioElement, HTMLVideoElement

Constant Summary collapse

NETWORK_EMPTY =
0
NETWORK_IDLE =
1
NETWORK_LOADING =
2
NETWORK_NO_SOURCE =
3
HAVE_NOTHING =
0
HAVE_METADATA =
1
HAVE_CURRENT_DATA =
2
HAVE_FUTURE_DATA =
3
HAVE_ENOUGH_DATA =
4

Constants inherited from Element

Element::ATTRIBUTE_NODE, Element::CDATA_SECTION_NODE, Element::COMMENT_NODE, Element::DOCUMENT_FRAGMENT_NODE, Element::DOCUMENT_NODE, Element::DOCUMENT_POSITION_CONTAINED_BY, Element::DOCUMENT_POSITION_CONTAINS, Element::DOCUMENT_POSITION_DISCONNECTED, Element::DOCUMENT_POSITION_FOLLOWING, Element::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Element::DOCUMENT_POSITION_PRECEDING, Element::DOCUMENT_TYPE_NODE, Element::ELEMENT_NODE, Element::PROCESSING_INSTRUCTION_NODE, Element::SHADOW_HOST_TAGS, Element::TEXT_NODE

Constants included from Node

Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_POSITION_CONTAINED_BY, Node::DOCUMENT_POSITION_CONTAINS, Node::DOCUMENT_POSITION_DISCONNECTED, Node::DOCUMENT_POSITION_FOLLOWING, Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Node::DOCUMENT_POSITION_PRECEDING, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE

Instance Attribute Summary

Attributes inherited from Element

#__node__, #document

Instance Method Summary collapse

Methods inherited from HTMLElement

#case_sensitive_attribute_names?

Methods inherited from Element

#[], #[]=, #__scroll_log__, #__shadow_root__, #after, #anchor_href, #animate, #append, #append_child, #attach_shadow, #attributes, #base_uri, #before, #blur, #child_element_count, #child_nodes, #children, #class_list, #class_name, #class_name=, #click, #clone_node, #closest, #compare_document_position, #contains?, #dataset, #equal_node?, #first_child, #first_element_child, #focus, #get_animations, #get_attribute, #get_attribute_node, #get_elements_by_class_name, #get_elements_by_tag_name, #get_html, #get_inner_html, #has_attribute?, #has_attributes?, #has_child_nodes?, #id, #id=, #initialize, #inner_html, #inner_html=, #insert_adjacent_element, #insert_adjacent_html, #insert_adjacent_text, #insert_before, #is_connected?, #last_child, #last_element_child, #live_child_nodes, #local_name, #matches?, #namespace_uri, #next_element_sibling, #next_sibling, #normalize, #on, #outer_html, #outer_html=, #owner_document, #parent_element, #parent_node, #prepend, #previous_element_sibling, #previous_sibling, #query_selector, #query_selector_all, #reflected_attr_name, #remove, #remove_attribute, #remove_attribute_node, #remove_child, #replace_child, #replace_children, #replace_with_nodes, #role, #role=, #root_node, #same_node?, #set_attribute, #set_attribute_node, #shadow_root, #slot, #slot=, #style, #tag_name, #text_content, #text_content=, #to_s, #toggle_attribute

Methods included from EventTarget

#__deliver_event__, #add_event_listener, #dispatch_event, #invoke_listener, #remove_event_listener

Constructor Details

This class inherits a constructor from Dommy::Element

Instance Method Details

#__js_call__(method, args) ⇒ Object



3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
# File 'lib/dommy/html_elements.rb', line 3313

def __js_call__(method, args)
  case method
  when "play"
    play
  when "pause"
    pause
  when "load"
    load
  when "canPlayType"
    can_play_type(args[0])
  else
    super
  end
end

#__js_get__(key) ⇒ Object



3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
# File 'lib/dommy/html_elements.rb', line 3221

def __js_get__(key)
  case key
  when "src"
    src
  when "currentSrc"
    current_src
  when "preload"
    preload
  when "crossOrigin"
    crossorigin
  when "autoplay"
    autoplay
  when "loop"
    loop_
  when "controls"
    controls
  when "muted"
    muted
  when "defaultMuted"
    default_muted
  when "paused"
    paused
  when "ended"
    ended
  when "seeking"
    seeking
  when "volume"
    volume
  when "playbackRate"
    playback_rate
  when "defaultPlaybackRate"
    default_playback_rate
  when "currentTime"
    current_time
  when "duration"
    duration
  when "networkState"
    network_state
  when "readyState"
    ready_state
  when "NETWORK_EMPTY"
    NETWORK_EMPTY
  when "NETWORK_IDLE"
    NETWORK_IDLE
  when "NETWORK_LOADING"
    NETWORK_LOADING
  when "NETWORK_NO_SOURCE"
    NETWORK_NO_SOURCE
  when "HAVE_NOTHING"
    HAVE_NOTHING
  when "HAVE_METADATA"
    HAVE_METADATA
  when "HAVE_CURRENT_DATA"
    HAVE_CURRENT_DATA
  when "HAVE_FUTURE_DATA"
    HAVE_FUTURE_DATA
  when "HAVE_ENOUGH_DATA"
    HAVE_ENOUGH_DATA
  else
    super
  end
end

#__js_set__(key, value) ⇒ Object



3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
# File 'lib/dommy/html_elements.rb', line 3284

def __js_set__(key, value)
  case key
  when "src"
    self.src = value
  when "preload"
    self.preload = value
  when "autoplay"
    self.autoplay = value
  when "loop"
    self.loop_ = value
  when "controls"
    self.controls = value
  when "muted"
    self.muted = value
  when "defaultMuted"
    self.default_muted = value
  when "volume"
    self.volume = value
  when "playbackRate"
    self.playback_rate = value
  when "defaultPlaybackRate"
    self.default_playback_rate = value
  when "currentTime"
    self.current_time = value
  else
    super
  end
end

#autoplayObject



3104
3105
3106
# File 'lib/dommy/html_elements.rb', line 3104

def autoplay
  reflected_boolean("autoplay")
end

#autoplay=(v) ⇒ Object



3108
3109
3110
# File 'lib/dommy/html_elements.rb', line 3108

def autoplay=(v)
  set_reflected_boolean("autoplay", v)
end

#can_play_type(_type) ⇒ Object



3216
3217
3218
3219
# File 'lib/dommy/html_elements.rb', line 3216

def can_play_type(_type)
  # spec: "" | "maybe" | "probably". We don't decode → "".
  ""
end

#controlsObject



3120
3121
3122
# File 'lib/dommy/html_elements.rb', line 3120

def controls
  reflected_boolean("controls")
end

#controls=(v) ⇒ Object



3124
3125
3126
# File 'lib/dommy/html_elements.rb', line 3124

def controls=(v)
  set_reflected_boolean("controls", v)
end

#crossoriginObject



3100
3101
3102
# File 'lib/dommy/html_elements.rb', line 3100

def crossorigin
  reflected_string("crossorigin")
end

#current_srcObject



3088
3089
3090
# File 'lib/dommy/html_elements.rb', line 3088

def current_src
  src
end

#current_timeObject



3180
3181
3182
# File 'lib/dommy/html_elements.rb', line 3180

def current_time
  @__current_time.to_f
end

#current_time=(v) ⇒ Object



3184
3185
3186
# File 'lib/dommy/html_elements.rb', line 3184

def current_time=(v)
  @__current_time = v.to_f
end

#default_mutedObject



3136
3137
3138
# File 'lib/dommy/html_elements.rb', line 3136

def default_muted
  reflected_boolean("muted")
end

#default_muted=(v) ⇒ Object



3140
3141
3142
# File 'lib/dommy/html_elements.rb', line 3140

def default_muted=(v)
  set_reflected_boolean("muted", v)
end

#default_playback_rateObject



3172
3173
3174
# File 'lib/dommy/html_elements.rb', line 3172

def default_playback_rate
  @__default_rate.nil? ? 1.0 : @__default_rate
end

#default_playback_rate=(v) ⇒ Object



3176
3177
3178
# File 'lib/dommy/html_elements.rb', line 3176

def default_playback_rate=(v)
  @__default_rate = v.to_f
end

#durationObject



3188
3189
3190
# File 'lib/dommy/html_elements.rb', line 3188

def duration
  Float::NAN
end

#endedObject



3148
3149
3150
# File 'lib/dommy/html_elements.rb', line 3148

def ended
  false
end

#loadObject



3212
3213
3214
# File 'lib/dommy/html_elements.rb', line 3212

def load
  nil
end

#loop_Object



3112
3113
3114
# File 'lib/dommy/html_elements.rb', line 3112

def loop_
  reflected_boolean("loop")
end

#loop_=(v) ⇒ Object



3116
3117
3118
# File 'lib/dommy/html_elements.rb', line 3116

def loop_=(v)
  set_reflected_boolean("loop", v)
end

#mutedObject



3128
3129
3130
# File 'lib/dommy/html_elements.rb', line 3128

def muted
  @__muted == true || reflected_boolean("muted")
end

#muted=(v) ⇒ Object



3132
3133
3134
# File 'lib/dommy/html_elements.rb', line 3132

def muted=(v)
  @__muted = !!v
end

#network_stateObject



3192
3193
3194
# File 'lib/dommy/html_elements.rb', line 3192

def network_state
  NETWORK_EMPTY
end

#pauseObject



3207
3208
3209
3210
# File 'lib/dommy/html_elements.rb', line 3207

def pause
  @__paused = true
  nil
end

#pausedObject



3144
3145
3146
# File 'lib/dommy/html_elements.rb', line 3144

def paused
  @__paused.nil? ? true : @__paused
end

#playObject



3200
3201
3202
3203
3204
3205
# File 'lib/dommy/html_elements.rb', line 3200

def play
  @__paused = false
  promise = PromiseValue.new(@document.default_view)
  promise.fulfill(nil)
  promise
end

#playback_rateObject



3164
3165
3166
# File 'lib/dommy/html_elements.rb', line 3164

def playback_rate
  @__rate.nil? ? 1.0 : @__rate
end

#playback_rate=(v) ⇒ Object



3168
3169
3170
# File 'lib/dommy/html_elements.rb', line 3168

def playback_rate=(v)
  @__rate = v.to_f
end

#preloadObject



3092
3093
3094
# File 'lib/dommy/html_elements.rb', line 3092

def preload
  reflected_string("preload")
end

#preload=(v) ⇒ Object



3096
3097
3098
# File 'lib/dommy/html_elements.rb', line 3096

def preload=(v)
  set_reflected_string("preload", v)
end

#ready_stateObject



3196
3197
3198
# File 'lib/dommy/html_elements.rb', line 3196

def ready_state
  HAVE_NOTHING
end

#seekingObject



3152
3153
3154
# File 'lib/dommy/html_elements.rb', line 3152

def seeking
  false
end

#srcObject



3080
3081
3082
# File 'lib/dommy/html_elements.rb', line 3080

def src
  reflected_string("src")
end

#src=(v) ⇒ Object



3084
3085
3086
# File 'lib/dommy/html_elements.rb', line 3084

def src=(v)
  set_reflected_string("src", v)
end

#volumeObject



3156
3157
3158
# File 'lib/dommy/html_elements.rb', line 3156

def volume
  @__volume.nil? ? 1.0 : @__volume
end

#volume=(v) ⇒ Object



3160
3161
3162
# File 'lib/dommy/html_elements.rb', line 3160

def volume=(v)
  @__volume = v.to_f
end