Class: Dommy::HTMLMediaElement
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.
Constant Summary
collapse
- NETWORK_EMPTY =
Own js_call methods, on top of Element’s.
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::HTML_NAMESPACE, Element::PROCESSING_INSTRUCTION_NODE, Element::REFLECTED_TOKEN_LIST_HOSTS, Element::SHADOW_HOST_TAGS, Element::SVG_NAMESPACE, 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::HTML_NAMESPACE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE
Instance Attribute Summary
Attributes inherited from Element
#document
Instance Method Summary
collapse
Methods inherited from HTMLElement
#case_sensitive_attribute_names?
included
Methods inherited from Element
#[], #[]=, #__dommy_backend_node__, #__internal_set_namespace__, #__internal_shadow_root__, #__test_scroll_log__, #access_key_label, #after, #anchor_href, #animate, #aria_content_attr, #aria_element_attr, #aria_element_get, #aria_element_set, #aria_elements_attr, #aria_elements_get, #aria_elements_set, #aria_find_in_root, #aria_get, #aria_set, #at_xpath, #attach_shadow, #attributes, #base_uri, #before, #blur, #child_element_count, #child_nodes, #children, #class_list, #class_name, #class_name=, #clear_aria_element_ref_for, #click, #clone_node, #closest, #contains?, #dataset, #element_prefix, #equal_node?, #first_child, #first_element_child, #focus, #get_animations, #get_attribute, #get_attribute_names, #get_attribute_node, #get_attribute_node_ns, #get_attribute_ns, #get_bounding_client_rect, #get_client_rects, #get_elements_by_class_name, #get_elements_by_tag_name, #get_elements_by_tag_name_ns, #get_html, #get_inner_html, #has_attribute?, #has_attribute_ns?, #has_attributes?, #has_child_nodes?, #hide_popover, #id, #id=, #initialize, #inner_html, #inner_html=, #insert_adjacent_element, #insert_adjacent_html, #insert_adjacent_text, #insert_before, #insertion_parent!, #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, #path, #previous_element_sibling, #previous_sibling, #query_selector, #query_selector_all, #reflected_attr_name, #reflected_token_list, #remove, #remove_attribute, #remove_attribute_node, #remove_attribute_ns, #remove_child, #replace_child, #replace_with_nodes, #request_fullscreen, #role, #role=, #root_node, #same_node?, #scoped_query, #set_attribute, #set_attribute_node, #set_attribute_ns, #shadow_root, #show_popover, #slot, #slot=, #style, #tag_name, #text_content, #text_content=, #to_s, #toggle_attribute, #toggle_popover, #with_selector_errors, #xpath
included
#append, #append_child, #prepend, #replace_children
Methods included from Node
#compare_document_position, #get_root_node, #is_default_namespace, #is_equal_node, #is_same_node, #lookup_namespace_uri, #lookup_prefix
#__internal_deliver_event__, #__internal_event_parent__, #add_event_listener, capture_flag, #deliver_at, #dispatch_event, js_truthy?, #remove_event_listener
Constructor Details
This class inherits a constructor from Dommy::Element
Instance Method Details
#__js_call__(method, args) ⇒ Object
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
|
# File 'lib/dommy/html_elements.rb', line 2521
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
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
|
# File 'lib/dommy/html_elements.rb', line 2454
def __js_get__(key)
case key
when "currentSrc"
current_src
when "muted"
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
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
|
# File 'lib/dommy/html_elements.rb', line 2503
def __js_set__(key, value)
case key
when "muted"
self.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
|
#can_play_type(_type) ⇒ Object
2449
2450
2451
2452
|
# File 'lib/dommy/html_elements.rb', line 2449
def can_play_type(_type)
""
end
|
#current_src ⇒ Object
2365
2366
2367
|
# File 'lib/dommy/html_elements.rb', line 2365
def current_src
src
end
|
#current_time ⇒ Object
2413
2414
2415
|
# File 'lib/dommy/html_elements.rb', line 2413
def current_time
@__current_time.to_f
end
|
#current_time=(v) ⇒ Object
2417
2418
2419
|
# File 'lib/dommy/html_elements.rb', line 2417
def current_time=(v)
@__current_time = v.to_f
end
|
#default_playback_rate ⇒ Object
2405
2406
2407
|
# File 'lib/dommy/html_elements.rb', line 2405
def default_playback_rate
@__default_rate.nil? ? 1.0 : @__default_rate
end
|
#default_playback_rate=(v) ⇒ Object
2409
2410
2411
|
# File 'lib/dommy/html_elements.rb', line 2409
def default_playback_rate=(v)
@__default_rate = v.to_f
end
|
#duration ⇒ Object
2421
2422
2423
|
# File 'lib/dommy/html_elements.rb', line 2421
def duration
Float::NAN
end
|
#ended ⇒ Object
2381
2382
2383
|
# File 'lib/dommy/html_elements.rb', line 2381
def ended
false
end
|
#load ⇒ Object
2445
2446
2447
|
# File 'lib/dommy/html_elements.rb', line 2445
def load
nil
end
|
#muted ⇒ Object
2369
2370
2371
|
# File 'lib/dommy/html_elements.rb', line 2369
def muted
@__muted == true || reflected_boolean("muted")
end
|
#muted=(v) ⇒ Object
2373
2374
2375
|
# File 'lib/dommy/html_elements.rb', line 2373
def muted=(v)
@__muted = !!v
end
|
#network_state ⇒ Object
2425
2426
2427
|
# File 'lib/dommy/html_elements.rb', line 2425
def network_state
NETWORK_EMPTY
end
|
#pause ⇒ Object
2440
2441
2442
2443
|
# File 'lib/dommy/html_elements.rb', line 2440
def pause
@__paused = true
nil
end
|
#paused ⇒ Object
2377
2378
2379
|
# File 'lib/dommy/html_elements.rb', line 2377
def paused
@__paused.nil? ? true : @__paused
end
|
#play ⇒ Object
2433
2434
2435
2436
2437
2438
|
# File 'lib/dommy/html_elements.rb', line 2433
def play
@__paused = false
promise = PromiseValue.new(@document.default_view)
promise.fulfill(nil)
promise
end
|
#playback_rate ⇒ Object
2397
2398
2399
|
# File 'lib/dommy/html_elements.rb', line 2397
def playback_rate
@__rate.nil? ? 1.0 : @__rate
end
|
#playback_rate=(v) ⇒ Object
2401
2402
2403
|
# File 'lib/dommy/html_elements.rb', line 2401
def playback_rate=(v)
@__rate = v.to_f
end
|
#ready_state ⇒ Object
2429
2430
2431
|
# File 'lib/dommy/html_elements.rb', line 2429
def ready_state
HAVE_NOTHING
end
|
#seeking ⇒ Object
2385
2386
2387
|
# File 'lib/dommy/html_elements.rb', line 2385
def seeking
false
end
|
#volume ⇒ Object
2389
2390
2391
|
# File 'lib/dommy/html_elements.rb', line 2389
def volume
@__volume.nil? ? 1.0 : @__volume
end
|
#volume=(v) ⇒ Object
2393
2394
2395
|
# File 'lib/dommy/html_elements.rb', line 2393
def volume=(v)
@__volume = v.to_f
end
|