View Javadoc
1   /*
2    * Copyright (c) 2002-2026 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.javascript.host.html;
16  
17  import org.htmlunit.html.HtmlVideo;
18  import org.htmlunit.javascript.configuration.JsxClass;
19  import org.htmlunit.javascript.configuration.JsxConstructor;
20  import org.htmlunit.javascript.configuration.JsxGetter;
21  import org.htmlunit.javascript.configuration.JsxSetter;
22  
23  /**
24   * The JavaScript object {@code HTMLVideoElement}.
25   *
26   * @author Ahmed Ashour
27   * @author Ronald Brill
28   * @author Frank Danek
29   *
30   * @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement">MDN Documentation</a>
31   */
32  @JsxClass(domClass = HtmlVideo.class)
33  public class HTMLVideoElement extends HTMLMediaElement {
34  
35      /**
36       * JavaScript constructor.
37       */
38      @Override
39      @JsxConstructor
40      public void jsConstructor() {
41          super.jsConstructor();
42      }
43  
44      /**
45       * Returns the {@code width} property.
46       * @return the {@code width} property
47       */
48      @JsxGetter
49      public int getWidth() {
50          final String value = getDomNodeOrDie().getAttributeDirect("width");
51          final Integer intValue = HTMLCanvasElement.getValue(value);
52          if (intValue != null) {
53              return intValue;
54          }
55          return 0;
56      }
57  
58      /**
59       * Sets the {@code width} property.
60       * @param width the {@code width} property
61       */
62      @JsxSetter
63      public void setWidth(final int width) {
64          getDomNodeOrDie().setAttribute("width", Integer.toString(width));
65      }
66  
67      /**
68       * Returns the {@code height} property.
69       * @return the {@code height} property
70       */
71      @JsxGetter
72      public int getHeight() {
73          final String value = getDomNodeOrDie().getAttributeDirect("height");
74          final Integer intValue = HTMLCanvasElement.getValue(value);
75          if (intValue != null) {
76              return intValue;
77          }
78          return 0;
79      }
80  
81      /**
82       * Sets the {@code height} property.
83       * @param height the {@code height} property
84       */
85      @JsxSetter
86      public void setHeight(final int height) {
87          getDomNodeOrDie().setAttribute("height", Integer.toString(height));
88      }
89  
90      @Override
91      protected String getNodeNameCustomize() {
92          return "VIDEO";
93      }
94  }