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