HTMLAudioElement
Tổng quan
HTMLAudioElement là một lớp trong Aspose.Html FOSS cho Python. Kế thừa từ: HTMLMediaElement.
HTML <audio> phần tử.
Lớp này cung cấp 83 phương thức để làm việc với các đối tượng HTMLAudioElement trong các chương trình Python. Các phương thức khả dụng bao gồm: __init__, add_event_listener, add_text_track, after, append, append_child, attach_shadow, before, blur, can_play_type, check_visibility, click, và 71 phương thức bổ sung. Tất cả các thành viên công khai đều có thể truy cập cho bất kỳ ứng dụng Python nào sau khi cài đặt gói Aspose.Html FOSS cho Python. Thuộc tính: access_key, access_key_label, assigned_slot, attributes, audio_tracks, auto_play, và 92 thuộc tính khác.
Thuộc tính
| Tên | Kiểu | Truy cập | Mô tả |
|---|---|---|---|
src | str | Đọc | Giá trị thuộc tính src, hoặc '' khi không có. |
current_src | str | Đọc | URL nguồn hiện đang được chọn (đầu mẫu, luôn là ''). |
auto_play | bool | Đọc | Phản chiếu Boolean của thuộc tính autoplay. |
controls | bool | Đọc | Phản chiếu Boolean của thuộc tính controls. |
loop | bool | Đọc | Phản chiếu Boolean của thuộc tính loop. |
muted | bool | Đọc | Phản ánh kiểu Boolean của thuộc tính muted. |
preload | str | Đọc | Giá trị thuộc tính preload, hoặc '' khi không có. |
cross_origin | `str | None` | Đọc |
paused | bool | Đọc | Trạng thái phát tạm dừng (mẫu, luôn luôn True). |
ended | bool | Đọc | Trạng thái phát đã kết thúc (mẫu, luôn luôn False). |
duration | float | Đọc | Thời lượng phương tiện tính bằng giây (đầu mẫu, luôn là NaN). |
current_time | float | Đọc/Ghi | Vị trí phát hiện tại tính bằng giây (đầu mẫu, luôn là 0.0). |
volume | float | Đọc/Ghi | Mức âm lượng âm thanh (đầu mẫu, luôn là 1.0). |
default_muted | bool | Đọc | Trạng thái tắt tiếng mặc định được phản ánh từ thuộc tính muted. |
ready_state | int | Đọc | Trạng thái sẵn sàng (stub, luôn 0 = HAVE_NOTHING). |
network_state | int | Đọc | Trạng thái mạng (stub, luôn 0 = NETWORK_EMPTY). |
buffered | "_TimeRanges" | Đọc | Các khoảng thời gian đã đệm (đoạn mẫu, luôn trống). |
played | "_TimeRanges" | Đọc | Các khoảng thời gian đã phát (đoạn mẫu, luôn trống). |
seekable | "_TimeRanges" | Đọc | Các khoảng thời gian có thể tìm kiếm (đoạn mẫu, luôn trống). |
seeking | bool | Đọc | Liệu phần tử hiện đang tìm kiếm (stub, luôn False). |
default_playback_rate | float | Đọc/Ghi | Tốc độ phát mặc định (headless mặc định 1.0). |
playback_rate | float | Đọc/Ghi | Tốc độ phát hiện tại (headless mặc định 1.0). |
media_keys | None | Đọc | Đối tượng MediaKeys liên quan (stub, luôn None). |
src_object | None | Đọc | Đối tượng MediaStream/Blob liên quan (stub, luôn None). |
error | None | Đọc | Lỗi media cuối cùng (stub, luôn None). |
text_tracks | "_EmptyTrackList" | Đọc | Danh sách track văn bản (stub, luôn trống). |
audio_tracks | "_EmptyTrackList" | Đọc | Danh sách track âm thanh (stub, luôn trống). |
video_tracks | "_EmptyTrackList" | Đọc | Danh sách các rãnh video (bản mẫu, luôn trống). |
hidden | bool | Đọc/Ghi | Liệu phần tử có bị ẩn hay không (phản ánh thuộc tính boolean hidden). |
title | str | Đọc/Ghi | Tiêu đề tooltip của phần tử này (phản ánh thuộc tính title). |
lang | str | Đọc/Ghi | Ngôn ngữ của nội dung phần tử (phản ánh thuộc tính lang). |
tab_index | int | Đọc/Ghi | Chỉ mục thứ tự tab của phần tử này (phản ánh thuộc tính tabindex). |
access_key | str | Đọc/Ghi | Phím tắt cho phần tử này (phản ánh accesskey |
attribute). || content_editable | str | Đọc/Ghi | Phản ánh thuộc tính contenteditable (WHATWG HTML §6.6). | | is_content_editable | bool | Đọc | Liệu phần tử này hiện có thể chỉnh sửa hay không (WHATWG HTML §6.6). | | dir | str | Đọc/Ghi | Hướng văn bản của phần tử (phản ánh thuộc tính dir). | | draggable | bool | Đọc/Ghi | Liệu phần tử có thể kéo được hay không (phản ánh thuộc tính draggable). | | spell_check | bool | Đọc/Ghi | Liệu kiểm tra chính tả có được bật hay không (phản ánh thuộc tính spellcheck). | | spellcheck | bool | Đọc/Ghi | Liệu kiểm tra chính tả có được bật hay không (phản ánh thuộc tính spellcheck). | | autocapitalize | str | Đọc/Ghi | Gợi ý tự động viết hoa (phản ánh thuộc tính autocapitalize). | | nonce | str | Đọc/Ghi | Nonce mật mã cho CSP (phản ánh thuộc tính nonce). | | autofocus | bool | Đọc/Ghi | Liệu phần tử này có nên nhận tiêu điểm khi tải trang hay không. | | access_key_label | str | Đọc | Nhãn phím truy cập do hệ thống gán (đầu giả không giao diện: luôn ''). | | input_mode | str | Đọc/Ghi | Gợi ý chế độ nhập bàn phím ảo (phản ánh thuộc tính inputmode). | | enter_key_hint | str | Đọc/Ghi | Gợi ý nhãn hành động phím Enter (phản ánh thuộc tính enterkeyhint). | | translate | bool | Đọc/Ghi | Liệu dịch thuật có được bật cho phần tử này hay không (WHATWG HTML §6.1.2). | | inner_text | str | Đọc/Ghi | Nội dung văn bản đã render — khoảng trắng đã thu gọn text_content. | | outer_text | str | Đọc/Ghi | Giống như inner_text (getter phản chiếu inner_text theo HTML Standard §3.2.7). | | popover | | Read/Write | Reflects thepopovercontent attribute (WHATWG HTML §6.12). | | node_name|str| Read | The qualified tag name (uppercase for HTML elements). | |tag_name|str| Read | The qualified tag name in uppercase (HTML elements). | |local_name|str| Read | The local part of the qualified name (lowercase). | |namespace_uri|str | None | Read | The namespace URI, orNonefor no namespace. | | style_sheets|“StyleSheetList”| Read | Live stylesheet list applicable to this element's document. | |prefix|str | None | Read | The namespace prefix, orNone. | | id|str| Read | The value of theidattribute, or’’if not present. | | class_name|str | Read | The value of theclassattribute, or’’. | | class_list|“DOMTokenList”| Read | Live mutable set of CSS class tokens backed by theclassattribute. | | dataset|“DOMStringMap” | Read | Live dict-like view of the element'sdata-*custom attributes. | | attributes|NamedNodeMap| Read | The ordered map of Attr objects for this element. | |children|HTMLCollection| Read | A live HTMLCollection of Element-type children only. | |first_element_child|Element | None | Read | The first Element child, orNone. | | last_element_child|Element | None| Read | The last Element child, orNone. | | next_element_sibling|Element | None| Read | The next sibling that is an Element, orNone. | | previous_element_sibling|Element | None| Read | The previous sibling that is an Element, orNone. | | child_element_count|int| Read | The number of Element children. | |inner_html|str| Read/Write | The serialised HTML content of all children (innerHTML). | |outer_html|str| Read/Write | The serialised HTML of this element and all its descendants (outerHTML). | |text_content|str | None| Read/Write | The concatenation of all descendant Text node data (DFS order). | |style|“CSSStyleDeclaration”| Read | The inline style of this element as a live CSSStyleDeclaration. | |scroll_width|int| Read | Content scroll width in CSS pixels (stub: 0). | |scroll_height|int| Read | Content scroll height in CSS pixels (stub: 0). | |client_width|int| Read | Inner width including padding, excluding border (stub: 0). | |client_height|int| Read | Inner height including padding, excluding border (stub: 0). | |scroll_top|int| Read/Write | Vertical scroll offset in CSS pixels (stub: 0). | |scroll_left|int| Read/Write | Horizontal scroll offset in CSS pixels (stub: 0). | |offset_width|int| Read | Layout border-box width in CSS pixels (stub: 0). | |offset_height|int| Read | Layout border-box height in CSS pixels (stub: 0). | |offset_top|int| Read | Top offset fromoffsetParentin CSS pixels (stub: 0). | | offset_left|int | Read | Left offset fromoffsetParentin CSS pixels (stub: 0). | | offset_parent|None | Read | The offset parent element; alwaysNonein headless mode. | | client_top|int | Read | Width of the top CSS border in pixels; always0in headless mode. | | client_left|int | Read | Width of the left CSS border in pixels; always0in headless mode. | | part|“DOMTokenList” | Read | Live DOMTokenList reflecting the elementpartattribute. | | shadow_root | | Đọc | Luôn None trong chế độ không giao diện. | | slot | str | Đọc/Ghi | Phản ánh thuộc tính nội dung slot (DOM §4.2.3). | | assigned_slot | | Read | AlwaysNonein headless mode. | | node_type|int | Read | Integer node type constant fromNodeType. | | node_value|str | None| Read/Write | Character data for CharacterData nodes;Noneotherwise. | | parent_node|Node | None | Read | The parent node, orNoneif this node has no parent. | | parent_element|Element | None | Read | The parent node if it is an Element;Noneotherwise. | | is_connected|bool| Read | Whether this node is part of a document's node tree (WHATWG DOM §4.4). | |owner_document|Document | None | Read | The Document this node belongs to, orNonefor Document itself. | | child_nodes|NodeList| Read | A live NodeList of all child nodes. | |first_child|Node | None | Read | The first child node, orNone. | | last_child|Node | None| Read | The last child node, orNone. | | previous_sibling|Node | None| Read | The preceding sibling node, orNone. | | next_sibling|Node | None| Read | The following sibling node, orNone``.
Phương thức
| Chữ ký | Mô tả |
|---|---|
play() | Bắt đầu phát lại (stub no-op). |
pause() | Tạm dừng phát lại (stub no-op). |
load() | Tải lại lựa chọn nguồn media (stub no-op). |
can_play_type(type: str) → str | Trả về '' — chế độ headless không thể phát bất kỳ loại media nào. |
add_text_track(kind: str, label: str, language: str) | Thêm một bản ghi văn bản (stub no-op, trả về None). |
click() | Gửi một sự kiện click tổng hợp trên phần tử này. |
| `focus(options: “dict | None”)` |
blur() | Gửi một sự kiện 'blur' không lan truyền trên phần tử này. |
show_popover() | Hiển thị phần tử này dưới dạng popover (no-op trong chế độ headless). |
hide_popover() | Ẩn popover của phần tử này (no-op trong chế độ headless). |
| `toggle_popover(force: “bool | None”)→bool` |
| `init(local_name: str, namespace_uri: str | None, prefix: str |
get_computed_style() → "ComputedStyleDeclaration" | Trả về các khai báo đã được giải quyết cascade giai đoạn-2 cho phần tử này. |
insert_adjacent_html(position: str, html: str) | Chèn đánh dấu HTML đã phân tích tương đối với phần tử này. |
insert_adjacent_text(position: str, text: str) | Chèn một nút văn bản tương đối với phần tử này. |
| `insert_adjacent_element(position: str, element: “Element | None”)→“Element |
get_attribute(name: str) → `str | None` |
set_attribute(name: str, value: str) | Đặt thuộc tính name to value, tạo nó nếu không tồn tại. |
remove_attribute(name: str) | Xóa thuộc tính name. |
has_attribute(name: str) → bool | Return True nếu thuộc tính name tồn tại trên phần tử này. |
get_attribute_node(name: str) → `“Attr | None”` |
set_attribute_node(attr: "Attr") → `“Attr | None”` |
remove_attribute_node(attr: "Attr") → "Attr" | Remove attr từ tập thuộc tính của phần tử này và trả về nó. |
| `get_attribute_node_ns(namespace_uri: str | None, local_name: str)→“Attr |
set_attribute_node_ns(attr: "Attr") → `“Attr | None”` |
| `remove_attribute_node_ns(namespace_uri: str | None, local_name: str)→“Attr”` |
| `get_attribute_ns(namespace_uri: str | None, local_name: str)→str |
| `set_attribute_ns(namespace_uri: str | None, qualified_name: str, value: str)` |
| `has_attribute_ns(namespace_uri: str | None, local_name: str)→bool` |
| `remove_attribute_ns(namespace_uri: str | None, local_name: str)` |
| `toggle_attribute(name: str, force: bool | None)→bool` |
get_attribute_names() → list[str] | Trả về các tên đủ điều kiện của tất cả các thuộc tính theo thứ tự thu thập. |
has_attributes() → bool | Trả về True khi phần tử này có một hoặc nhiều thuộc tính. |
| `scroll_into_view(arg: bool | dict |
| `scroll(x_or_options: float | dict |
scroll_into_view_if_needed(center_if_needed: bool) | Cuộn phần tử này vào vùng hiển thị nếu nó chưa hiển thị (không thực hiện gì trong chế độ không giao diện). |
set_pointer_capture(pointer_id: int) | Chỉ định phần tử này làm mục tiêu bắt giữ cho con trỏ đã cho (không thực hiện gì). |
release_pointer_capture(pointer_id: int) | Giải phóng việc bắt giữ con trỏ cho id con trỏ đã cho (không thực hiện gì). |
has_pointer_capture(pointer_id: int) → bool | Trả về việc phần tử này có bắt giữ con trỏ cho id đã cho hay không. |
request_pointer_lock() | Yêu cầu khóa con trỏ vào phần tử này (không thực hiện gì). |
| `request_fullscreen(options: “dict | None”)` |
| `check_visibility(options: “dict | None”)→bool` |
query_selector(selector: str) → `Element | None` |
query_selector_all(selector: str) → NodeList | Trả về một NodeList tĩnh của tất cả các phần tử phù hợp selector. |
matches(selector: str) → bool | Return True nếu phần tử này khớp với CSS selector. |
webkit_matches_selector(selector: str) → bool | Bí danh tương thích trình duyệt cho :meth:matches. |
closest(selector: str) → `“Element | None”` |
get_elements_by_tag_name(qualified_name: str) → HTMLCollection | Trả về tất cả các phần tử con có tên thẻ khớp với qualified_name. |
get_elements_by_class_name(class_names: str) → HTMLCollection | Trả về tất cả các phần tử con mà mang tất cả các token lớp đã cho. |
filter_fn(el: "Element") → bool | Gọi filter_fn(el) trên đối tượng HTMLAudioElement này. |
remove() | Xóa phần tử này khỏi nút cha của nó. |
before() | Insert nodes ngay trước phần tử này trong nút cha của nó. |
after() | Insert nodes ngay sau phần tử này trong phần tử cha của nó. |
replace_with() | Thay thế phần tử này bằng nodes trong phần tử cha của nó. |
prepend() | Insert nodes trước đứa con đầu tiên của phần tử này. |
append() | Append nodes như là các phần tử con cuối cùng của phần tử này. |
replace_children() | Xóa tất cả các phần tử con, sau đó thêm nodes làm các phần tử con mới. |
get_bounding_client_rect() → "DOMRect" | Trả về hình chữ nhật bao quanh client (mẫu toàn bộ bằng 0). |
get_client_rects() → "DOMRectList" | Trả về danh sách hình chữ nhật client (trống trong ngữ cảnh phía máy chủ). |
get_animations() → list[object] | Trả về các hoạt ảnh đang hoạt động cho phần tử này (đoạn mô phỏng không giao diện: luôn []). |
| `attach_shadow(init: “dict | None”)` |
get_root_node(composed: bool) → "Node" | Trả về nút gốc của cây node. |
has_child_nodes() → bool | Trả về liệu nút này có ít nhất một nút con trực tiếp hay không. |
| `lookup_namespace_uri(prefix: str | None)→str |
| `lookup_prefix(namespace_uri: str | None)→str |
| `is_default_namespace(namespace_uri: str | None)→bool` |
| `is_supported(feature: str, version: str | None)→bool` |
| `get_feature(feature: str, version: str | None)→object |
| `set_user_data(key: str, data: object | None, handler: object |
get_user_data(key: str) → `object | None` |
append_child(node: Node) → Node | Append node là nút con cuối cùng của nút này. |
| `insert_before(node: Node, reference: Node | None)→Node` |
remove_child(node: Node) → Node | Remove node từ danh sách các nút con và trả về nó. |
replace_child(new_child: Node, old_child: Node) → Node | Replace old_child with new_child. |
clone_node(deep: bool) → Node | Trả về một bản sao của nút này. |
normalize() | Đưa nút này và toàn bộ cây con của nó vào dạng chuẩn hoá. |
| `contains(other: Node | None)→bool` |
compare_document_position(other: "Node") → int | Trả về một bitmask mô tả vị trí của other so với nút này. |
| `is_equal_node(other: Node | None)→bool` |
| `is_same_node(other_node: Node | None)→bool` |
add_event_listener(type: str, listener: Callable, capture: bool, once: bool) | Register listener cho các sự kiện của type. |
remove_event_listener(type: str, listener: Callable, capture: bool) | Hủy đăng ký một bộ lắng nghe đã được đăng ký trước đó. |
dispatch_event(event: "Event") → bool | Dispatch event qua cây tổ tiên. |