001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.html5; 018 019import java.net.*; 020 021import org.apache.juneau.*; 022import org.apache.juneau.annotation.*; 023import org.apache.juneau.internal.*; 024 025/** 026 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#the-video-element"><video></a> 027 * element. 028 * 029 * <p> 030 * The video element is used to embed video content in an HTML document. It provides a way to include 031 * video files that can be played by the browser's built-in video player. The video element supports 032 * multiple video formats and provides various attributes for controlling playback, appearance, and 033 * behavior. It can contain source elements to specify multiple video formats for browser compatibility. 034 * 035 * <h5 class='section'>Examples:</h5> 036 * <p class='bcode w800'> 037 * <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*; 038 * 039 * <jc>// Simple video with controls</jc> 040 * Video <jv>simple</jv> = <jsm>video</jsm>() 041 * .src(<js>"movie.mp4"</js>) 042 * .controls(<jk>true</jk>) 043 * .width(640) 044 * .height(360); 045 * 046 * <jc>// Video with multiple sources</jc> 047 * Video <jv>multiple</jv> = <jsm>video</jsm>( 048 * <jsm>source</jsm>().src(<js>"movie.mp4"</js>).type(<js>"video/mp4"</js>), 049 * <jsm>source</jsm>().src(<js>"movie.webm"</js>).type(<js>"video/webm"</js>), 050 * <jsm>source</jsm>().src(<js>"movie.ogg"</js>).type(<js>"video/ogg"</js>) 051 * ).controls(<jk>true</jk>); 052 * 053 * <jc>// Autoplay video (muted for browser compatibility)</jc> 054 * Video <jv>autoplay</jv> = <jsm>video</jsm>() 055 * .src(<js>"intro.mp4"</js>) 056 * .autoplay(<jk>true</jk>) 057 * .muted(<jk>true</jk>) 058 * .loop(<jk>true</jk>); 059 * 060 * <jc>// Video with poster image</jc> 061 * Video <jv>poster</jv> = <jsm>video</jsm>() 062 * .src(<js>"trailer.mp4"</js>) 063 * .poster(<js>"trailer-poster.jpg"</js>) 064 * .controls(<jk>true</jk>) 065 * .width(800) 066 * .height(450); 067 * 068 * <jc>// Video with custom styling</jc> 069 * Video <jv>styled</jv> = <jsm>video</jsm>() 070 * .src("presentation.mp4") 071 * .controls(true) 072 * ._class("video-player") 073 * .style("border: 2px solid #ccc; border-radius: 8px;"); 074 * 075 * // Video with event handlers 076 * Video interactive = new Video() 077 * .src("tutorial.mp4") 078 * .controls(true) 079 * .onplay("trackVideoPlay()") 080 * .onended("showNextVideo()"); 081 * </p> 082 * 083 * <p> 084 * The following convenience methods are provided for constructing instances of this bean: 085 * <ul class='javatree'> 086 * <li class='jc'>{@link HtmlBuilder} 087 * <ul class='javatree'> 088 * <li class='jm'>{@link HtmlBuilder#video() video()} 089 * <li class='jm'>{@link HtmlBuilder#video(Object, Object...) video(Object, Object...)} 090 * </ul> 091 * </ul> 092 * </p> 093 * 094 * <h5 class='section'>See Also:</h5><ul> 095 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 096 * </ul> 097 */ 098@Bean(typeName="video") 099public class Video extends HtmlElementMixed { 100 101 /** 102 * Creates an empty {@link Video} element. 103 */ 104 public Video() {} 105 106 /** 107 * Creates a {@link Video} element with the specified {@link Video#src(Object)} attribute. 108 * 109 * @param src The {@link Video#src(Object)} attribute. 110 */ 111 public Video(Object src) { 112 src(src); 113 } 114 115 /** 116 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-autoplay">autoplay</a> 117 * attribute. 118 * 119 * <p> 120 * Hint that the media resource can be started automatically when the page is loaded. 121 * 122 * <p> 123 * This attribute uses deminimized values: 124 * <ul> 125 * <li><jk>false</jk> - Attribute is not added</li> 126 * <li><jk>true</jk> - Attribute is added as <js>"autoplay"</js></li> 127 * <li>Other values - Passed through as-is</li> 128 * </ul> 129 * 130 * @param autoplay 131 * The new value for this attribute. 132 * Typically a {@link Boolean} or {@link String}. 133 * @return This object. 134 */ 135 public Video autoplay(Object value) { 136 attr("autoplay", deminimize(value, "autoplay")); 137 return this; 138 } 139 140 /** 141 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-controls">controls</a> 142 * attribute. 143 * 144 * <p> 145 * Show user agent controls. 146 * 147 * <p> 148 * This attribute uses deminimized values: 149 * <ul> 150 * <li><jk>false</jk> - Attribute is not added</li> 151 * <li><jk>true</jk> - Attribute is added as <js>"controls"</js></li> 152 * <li>Other values - Passed through as-is</li> 153 * </ul> 154 * 155 * @param controls 156 * The new value for this attribute. 157 * Typically a {@link Boolean} or {@link String}. 158 * @return This object. 159 */ 160 public Video controls(Object value) { 161 attr("controls", deminimize(value, "controls")); 162 return this; 163 } 164 165 /** 166 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-crossorigin">crossorigin</a> 167 * attribute. 168 * 169 * <p> 170 * Specifies how the element handles cross-origin requests for CORS (Cross-Origin Resource Sharing). 171 * 172 * <p> 173 * Possible values: 174 * <ul> 175 * <li><js>"anonymous"</js> - Cross-origin requests are made without credentials</li> 176 * <li><js>"use-credentials"</js> - Cross-origin requests include credentials</li> 177 * </ul> 178 * 179 * @param crossorigin How to handle cross-origin requests. 180 * @return This object. 181 */ 182 public Video crossorigin(String value) { 183 attr("crossorigin", value); 184 return this; 185 } 186 187 /** 188 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height">height</a> 189 * attribute. 190 * 191 * <p> 192 * Vertical dimension. 193 * 194 * @param height 195 * The new value for this attribute. 196 * Typically a {@link Number} or {@link String}. 197 * @return This object. 198 */ 199 public Video height(Object value) { 200 attr("height", value); 201 return this; 202 } 203 204 /** 205 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-loop">loop</a> attribute. 206 * 207 * <p> 208 * Causes the media to automatically restart from the beginning when it reaches the end. 209 * 210 * @param loop If <jk>true</jk>, the media will loop continuously. 211 * @return This object. 212 */ 213 public Video loop(Object value) { 214 attr("loop", value); 215 return this; 216 } 217 218 /** 219 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-mediagroup">mediagroup</a> 220 * attribute. 221 * 222 * <p> 223 * Groups multiple media elements together so they can be controlled as a single unit. All media elements 224 * with the same mediagroup value will share the same MediaController, allowing synchronized playback. 225 * 226 * <p> 227 * This is useful for creating synchronized audio/video presentations or multiple camera angles. 228 * 229 * @param mediagroup The name of the media group to join. 230 * @return This object. 231 */ 232 public Video mediagroup(String value) { 233 attr("mediagroup", value); 234 return this; 235 } 236 237 /** 238 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-muted">muted</a> 239 * attribute. 240 * 241 * <p> 242 * Mutes the audio output by default. Useful for autoplay videos where audio should be disabled initially. 243 * 244 * @param muted If <jk>true</jk>, the media will be muted by default. 245 * @return This object. 246 */ 247 public Video muted(Object value) { 248 attr("muted", value); 249 return this; 250 } 251 252 /** 253 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-video-poster">poster</a> 254 * attribute. 255 * 256 * <p> 257 * Specifies an image to display as a placeholder before the video starts playing. This image is shown 258 * while the video is loading or before the user clicks play. 259 * 260 * <p> 261 * The poster image should be representative of the video content and help users understand what the video contains. 262 * 263 * @param poster The URL of the poster image to display before video playback. 264 * @return This object. 265 */ 266 public Video poster(String value) { 267 attr("poster", value); 268 return this; 269 } 270 271 /** 272 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-preload">preload</a> 273 * attribute. 274 * 275 * <p> 276 * Specifies how the browser should load the media resource. 277 * 278 * <p> 279 * Possible values: 280 * <ul> 281 * <li><js>"none"</js> - Do not preload the media</li> 282 * <li><js>"metadata"</js> - Preload only metadata (duration, dimensions, etc.)</li> 283 * <li><js>"auto"</js> - Preload the entire media file (default)</li> 284 * </ul> 285 * 286 * @param preload How much of the media to preload. 287 * @return This object. 288 */ 289 public Video preload(String value) { 290 attr("preload", value); 291 return this; 292 } 293 294 /** 295 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-src">src</a> attribute. 296 * 297 * <p> 298 * Address of the resource. 299 * 300 * <p> 301 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 302 * Strings must be valid URIs. 303 * 304 * <p> 305 * URIs defined by {@link UriResolver} can be used for values. 306 * 307 * @param src 308 * The new value for this attribute. 309 * Typically a {@link URL} or {@link String}. 310 * @return This object. 311 */ 312 public Video src(Object value) { 313 attrUri("src", value); 314 return this; 315 } 316 317 /** 318 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width">width</a> attribute. 319 * 320 * <p> 321 * Horizontal dimension. 322 * 323 * @param width 324 * The new value for this attribute. 325 * Typically a {@link Number} or {@link String}. 326 * @return This object. 327 */ 328 public Video width(Object value) { 329 attr("width", value); 330 return this; 331 } 332 333 //----------------------------------------------------------------------------------------------------------------- 334 // Overridden methods 335 //----------------------------------------------------------------------------------------------------------------- 336 @Override /* Overridden from HtmlElement */ 337 public Video _class(String value) { // NOSONAR - Intentional naming. 338 super._class(value); 339 return this; 340 } 341 342 @Override /* Overridden from HtmlElement */ 343 public Video accesskey(String value) { 344 super.accesskey(value); 345 return this; 346 } 347 348 @Override /* Overridden from HtmlElement */ 349 public Video contenteditable(Object value) { 350 super.contenteditable(value); 351 return this; 352 } 353 354 @Override /* Overridden from HtmlElement */ 355 public Video dir(String value) { 356 super.dir(value); 357 return this; 358 } 359 360 @Override /* Overridden from HtmlElement */ 361 public Video hidden(Object value) { 362 super.hidden(value); 363 return this; 364 } 365 366 @Override /* Overridden from HtmlElement */ 367 public Video id(String value) { 368 super.id(value); 369 return this; 370 } 371 372 @Override /* Overridden from HtmlElement */ 373 public Video lang(String value) { 374 super.lang(value); 375 return this; 376 } 377 378 @Override /* Overridden from HtmlElement */ 379 public Video onabort(String value) { 380 super.onabort(value); 381 return this; 382 } 383 384 @Override /* Overridden from HtmlElement */ 385 public Video onblur(String value) { 386 super.onblur(value); 387 return this; 388 } 389 390 @Override /* Overridden from HtmlElement */ 391 public Video oncancel(String value) { 392 super.oncancel(value); 393 return this; 394 } 395 396 @Override /* Overridden from HtmlElement */ 397 public Video oncanplay(String value) { 398 super.oncanplay(value); 399 return this; 400 } 401 402 @Override /* Overridden from HtmlElement */ 403 public Video oncanplaythrough(String value) { 404 super.oncanplaythrough(value); 405 return this; 406 } 407 408 @Override /* Overridden from HtmlElement */ 409 public Video onchange(String value) { 410 super.onchange(value); 411 return this; 412 } 413 414 @Override /* Overridden from HtmlElement */ 415 public Video onclick(String value) { 416 super.onclick(value); 417 return this; 418 } 419 420 @Override /* Overridden from HtmlElement */ 421 public Video oncuechange(String value) { 422 super.oncuechange(value); 423 return this; 424 } 425 426 @Override /* Overridden from HtmlElement */ 427 public Video ondblclick(String value) { 428 super.ondblclick(value); 429 return this; 430 } 431 432 @Override /* Overridden from HtmlElement */ 433 public Video ondurationchange(String value) { 434 super.ondurationchange(value); 435 return this; 436 } 437 438 @Override /* Overridden from HtmlElement */ 439 public Video onemptied(String value) { 440 super.onemptied(value); 441 return this; 442 } 443 444 @Override /* Overridden from HtmlElement */ 445 public Video onended(String value) { 446 super.onended(value); 447 return this; 448 } 449 450 @Override /* Overridden from HtmlElement */ 451 public Video onerror(String value) { 452 super.onerror(value); 453 return this; 454 } 455 456 @Override /* Overridden from HtmlElement */ 457 public Video onfocus(String value) { 458 super.onfocus(value); 459 return this; 460 } 461 462 @Override /* Overridden from HtmlElement */ 463 public Video oninput(String value) { 464 super.oninput(value); 465 return this; 466 } 467 468 @Override /* Overridden from HtmlElement */ 469 public Video oninvalid(String value) { 470 super.oninvalid(value); 471 return this; 472 } 473 474 @Override /* Overridden from HtmlElement */ 475 public Video onkeydown(String value) { 476 super.onkeydown(value); 477 return this; 478 } 479 480 @Override /* Overridden from HtmlElement */ 481 public Video onkeypress(String value) { 482 super.onkeypress(value); 483 return this; 484 } 485 486 @Override /* Overridden from HtmlElement */ 487 public Video onkeyup(String value) { 488 super.onkeyup(value); 489 return this; 490 } 491 492 @Override /* Overridden from HtmlElement */ 493 public Video onload(String value) { 494 super.onload(value); 495 return this; 496 } 497 498 @Override /* Overridden from HtmlElement */ 499 public Video onloadeddata(String value) { 500 super.onloadeddata(value); 501 return this; 502 } 503 504 @Override /* Overridden from HtmlElement */ 505 public Video onloadedmetadata(String value) { 506 super.onloadedmetadata(value); 507 return this; 508 } 509 510 @Override /* Overridden from HtmlElement */ 511 public Video onloadstart(String value) { 512 super.onloadstart(value); 513 return this; 514 } 515 516 @Override /* Overridden from HtmlElement */ 517 public Video onmousedown(String value) { 518 super.onmousedown(value); 519 return this; 520 } 521 522 @Override /* Overridden from HtmlElement */ 523 public Video onmouseenter(String value) { 524 super.onmouseenter(value); 525 return this; 526 } 527 528 @Override /* Overridden from HtmlElement */ 529 public Video onmouseleave(String value) { 530 super.onmouseleave(value); 531 return this; 532 } 533 534 @Override /* Overridden from HtmlElement */ 535 public Video onmousemove(String value) { 536 super.onmousemove(value); 537 return this; 538 } 539 540 @Override /* Overridden from HtmlElement */ 541 public Video onmouseout(String value) { 542 super.onmouseout(value); 543 return this; 544 } 545 546 @Override /* Overridden from HtmlElement */ 547 public Video onmouseover(String value) { 548 super.onmouseover(value); 549 return this; 550 } 551 552 @Override /* Overridden from HtmlElement */ 553 public Video onmouseup(String value) { 554 super.onmouseup(value); 555 return this; 556 } 557 558 @Override /* Overridden from HtmlElement */ 559 public Video onmousewheel(String value) { 560 super.onmousewheel(value); 561 return this; 562 } 563 564 @Override /* Overridden from HtmlElement */ 565 public Video onpause(String value) { 566 super.onpause(value); 567 return this; 568 } 569 570 @Override /* Overridden from HtmlElement */ 571 public Video onplay(String value) { 572 super.onplay(value); 573 return this; 574 } 575 576 @Override /* Overridden from HtmlElement */ 577 public Video onplaying(String value) { 578 super.onplaying(value); 579 return this; 580 } 581 582 @Override /* Overridden from HtmlElement */ 583 public Video onprogress(String value) { 584 super.onprogress(value); 585 return this; 586 } 587 588 @Override /* Overridden from HtmlElement */ 589 public Video onratechange(String value) { 590 super.onratechange(value); 591 return this; 592 } 593 594 @Override /* Overridden from HtmlElement */ 595 public Video onreset(String value) { 596 super.onreset(value); 597 return this; 598 } 599 600 @Override /* Overridden from HtmlElement */ 601 public Video onresize(String value) { 602 super.onresize(value); 603 return this; 604 } 605 606 @Override /* Overridden from HtmlElement */ 607 public Video onscroll(String value) { 608 super.onscroll(value); 609 return this; 610 } 611 612 @Override /* Overridden from HtmlElement */ 613 public Video onseeked(String value) { 614 super.onseeked(value); 615 return this; 616 } 617 618 @Override /* Overridden from HtmlElement */ 619 public Video onseeking(String value) { 620 super.onseeking(value); 621 return this; 622 } 623 624 @Override /* Overridden from HtmlElement */ 625 public Video onselect(String value) { 626 super.onselect(value); 627 return this; 628 } 629 630 @Override /* Overridden from HtmlElement */ 631 public Video onshow(String value) { 632 super.onshow(value); 633 return this; 634 } 635 636 @Override /* Overridden from HtmlElement */ 637 public Video onstalled(String value) { 638 super.onstalled(value); 639 return this; 640 } 641 642 @Override /* Overridden from HtmlElement */ 643 public Video onsubmit(String value) { 644 super.onsubmit(value); 645 return this; 646 } 647 648 @Override /* Overridden from HtmlElement */ 649 public Video onsuspend(String value) { 650 super.onsuspend(value); 651 return this; 652 } 653 654 @Override /* Overridden from HtmlElement */ 655 public Video ontimeupdate(String value) { 656 super.ontimeupdate(value); 657 return this; 658 } 659 660 @Override /* Overridden from HtmlElement */ 661 public Video ontoggle(String value) { 662 super.ontoggle(value); 663 return this; 664 } 665 666 @Override /* Overridden from HtmlElement */ 667 public Video onvolumechange(String value) { 668 super.onvolumechange(value); 669 return this; 670 } 671 672 @Override /* Overridden from HtmlElement */ 673 public Video onwaiting(String value) { 674 super.onwaiting(value); 675 return this; 676 } 677 678 @Override /* Overridden from HtmlElement */ 679 public Video spellcheck(Object value) { 680 super.spellcheck(value); 681 return this; 682 } 683 684 @Override /* Overridden from HtmlElement */ 685 public Video style(String value) { 686 super.style(value); 687 return this; 688 } 689 690 @Override /* Overridden from HtmlElement */ 691 public Video tabindex(Object value) { 692 super.tabindex(value); 693 return this; 694 } 695 696 @Override /* Overridden from HtmlElement */ 697 public Video title(String value) { 698 super.title(value); 699 return this; 700 } 701 702 @Override /* Overridden from HtmlElement */ 703 public Video translate(Object value) { 704 super.translate(value); 705 return this; 706 } 707 708 @Override /* Overridden from HtmlElementContainer */ 709 public Video child(Object value) { 710 super.child(value); 711 return this; 712 } 713 714 @Override /* Overridden from HtmlElementContainer */ 715 public Video children(Object...value) { 716 super.children(value); 717 return this; 718 } 719}