001package Torello.Browser.BrowserAPI; 002 003import java.util.*; 004import javax.json.*; 005import javax.json.stream.*; 006import java.io.*; 007 008import java.lang.reflect.Method; 009import java.lang.reflect.Parameter; 010import java.util.function.Function; 011 012import Torello.Browser.BrowserEvent; 013import Torello.Browser.JavaScriptAPI.*; 014import Torello.Browser.helper.*; 015 016import Torello.Java.Additional.*; 017import Torello.Java.JSON.*; 018 019import static Torello.Java.JSON.JFlag.*; 020 021import Torello.Java.StrCmpr; 022import Torello.JavaDoc.StaticFunctional; 023import Torello.JavaDoc.JDHeaderBackgroundImg; 024import Torello.JavaDoc.Excuse; 025 026/** 027 * <SPAN CLASS=COPIEDJDK><B>This domain allows detailed inspection of media elements</B></SPAN> 028 * 029 * <EMBED CLASS='external-html' DATA-FILE-ID=CODE_GEN_NOTE> 030 */ 031@StaticFunctional(Excused={"counter"}, Excuses={Excuse.CONFIGURATION}) 032@JDHeaderBackgroundImg(EmbedTagFileID="WOOD_PLANK_NOTE") 033public class Media 034{ 035 // ******************************************************************************************** 036 // ******************************************************************************************** 037 // Class Header Stuff 038 // ******************************************************************************************** 039 // ******************************************************************************************** 040 041 042 // No Pubic Constructors 043 private Media () { } 044 045 // These two Vector's are used by all the "Methods" exported by this class. java.lang.reflect 046 // is used to generate the JSON String's. It saves thousands of lines of Auto-Generated Code. 047 private static final Map<String, Vector<String>> parameterNames = new HashMap<>(); 048 private static final Map<String, Vector<Class<?>>> parameterTypes = new HashMap<>(); 049 050 // Some Methods do not take any parameters - for instance all the "enable()" and "disable()" 051 // I simply could not get ride of RAW-TYPES and UNCHECKED warnings... so there are now, 052 // offically, two empty-vectors. One for String's, and the other for Classes. 053 054 private static final Vector<String> EMPTY_VEC_STR = new Vector<>(); 055 private static final Vector<Class<?>> EMPTY_VEC_CLASS = new Vector<>(); 056 057 static 058 { 059 for (Method m : Media.class.getMethods()) 060 { 061 // This doesn't work! The parameter names are all "arg0" ... "argN" 062 // It works for java.lang.reflect.Field, BUT NOT java.lang.reflect.Parameter! 063 // 064 // Vector<String> parameterNamesList = new Vector<>(); -- NOPE! 065 066 Vector<Class<?>> parameterTypesList = new Vector<>(); 067 068 for (Parameter p : m.getParameters()) parameterTypesList.add(p.getType()); 069 070 parameterTypes.put( 071 m.getName(), 072 (parameterTypesList.size() > 0) ? parameterTypesList : EMPTY_VEC_CLASS 073 ); 074 } 075 } 076 077 static 078 { 079 Vector<String> v = null; 080 081 parameterNames.put("enable", EMPTY_VEC_STR); 082 083 parameterNames.put("disable", EMPTY_VEC_STR); 084 } 085 086 087 // ******************************************************************************************** 088 // ******************************************************************************************** 089 // Types - Static Inner Classes 090 // ******************************************************************************************** 091 // ******************************************************************************************** 092 093 // public static class PlayerId => String 094 095 // public static class Timestamp => Number 096 097 /** 098 * Have one type per entry in MediaLogRecord::Type 099 * Corresponds to kMessage 100 */ 101 public static class PlayerMessage 102 extends BaseType 103 implements java.io.Serializable 104 { 105 /** For Object Serialization. java.io.Serializable */ 106 protected static final long serialVersionUID = 1; 107 108 public boolean[] optionals() 109 { return new boolean[] { false, false, }; } 110 111 /** 112 * Keep in sync with MediaLogMessageLevel 113 * We are currently keeping the message level 'error' separate from the 114 * PlayerError type because right now they represent different things, 115 * this one being a DVLOG(ERROR) style log message that gets printed 116 * based on what log level is selected in the UI, and the other is a 117 * representation of a media::PipelineStatus object. Soon however we're 118 * going to be moving away from using PipelineStatus for errors and 119 * introducing a new error type which should hopefully let us integrate 120 * the error log level into the PlayerError type. 121 */ 122 public final String level; 123 124 /** <CODE>[No Description Provided by Google]</CODE> */ 125 public final String message; 126 127 /** 128 * Constructor 129 * 130 * @param level 131 * Keep in sync with MediaLogMessageLevel 132 * We are currently keeping the message level 'error' separate from the 133 * PlayerError type because right now they represent different things, 134 * this one being a DVLOG(ERROR) style log message that gets printed 135 * based on what log level is selected in the UI, and the other is a 136 * representation of a media::PipelineStatus object. Soon however we're 137 * going to be moving away from using PipelineStatus for errors and 138 * introducing a new error type which should hopefully let us integrate 139 * the error log level into the PlayerError type. 140 * <BR />Acceptable Values: ["error", "warning", "info", "debug"] 141 * 142 * @param message - 143 */ 144 public PlayerMessage(String level, String message) 145 { 146 // Exception-Check(s) to ensure that if any parameters which are not declared as 147 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 148 149 if (level == null) THROWS.throwNPE("level"); 150 if (message == null) THROWS.throwNPE("message"); 151 152 // Exception-Check(s) to ensure that if any parameters which must adhere to a 153 // provided List of Enumerated Values, fails, then IllegalArgumentException shall throw. 154 155 THROWS.checkIAE( 156 "level", level, 157 "error", "warning", "info", "debug" 158 ); 159 160 this.level = level; 161 this.message = message; 162 } 163 164 /** 165 * JSON Object Constructor 166 * @param jo A Json-Object having data about an instance of {@code 'PlayerMessage'}. 167 */ 168 public PlayerMessage (JsonObject jo) 169 { 170 this.level = ReadJSON.getString(jo, "level", false, true); 171 this.message = ReadJSON.getString(jo, "message", false, true); 172 } 173 174 175 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 176 public boolean equals(Object other) 177 { 178 if (this == other) return true; 179 if (other == null) return false; 180 if (other.getClass() != this.getClass()) return false; 181 182 PlayerMessage o = (PlayerMessage) other; 183 184 return 185 Objects.equals(this.level, o.level) 186 && Objects.equals(this.message, o.message); 187 } 188 189 /** Generates a Hash-Code for {@code 'this'} instance */ 190 public int hashCode() 191 { 192 return 193 Objects.hashCode(this.level) 194 + Objects.hashCode(this.message); 195 } 196 } 197 198 /** Corresponds to kMediaPropertyChange */ 199 public static class PlayerProperty 200 extends BaseType 201 implements java.io.Serializable 202 { 203 /** For Object Serialization. java.io.Serializable */ 204 protected static final long serialVersionUID = 1; 205 206 public boolean[] optionals() 207 { return new boolean[] { false, false, }; } 208 209 /** <CODE>[No Description Provided by Google]</CODE> */ 210 public final String name; 211 212 /** <CODE>[No Description Provided by Google]</CODE> */ 213 public final String value; 214 215 /** 216 * Constructor 217 * 218 * @param name - 219 * 220 * @param value - 221 */ 222 public PlayerProperty(String name, String value) 223 { 224 // Exception-Check(s) to ensure that if any parameters which are not declared as 225 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 226 227 if (name == null) THROWS.throwNPE("name"); 228 if (value == null) THROWS.throwNPE("value"); 229 230 this.name = name; 231 this.value = value; 232 } 233 234 /** 235 * JSON Object Constructor 236 * @param jo A Json-Object having data about an instance of {@code 'PlayerProperty'}. 237 */ 238 public PlayerProperty (JsonObject jo) 239 { 240 this.name = ReadJSON.getString(jo, "name", false, true); 241 this.value = ReadJSON.getString(jo, "value", false, true); 242 } 243 244 245 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 246 public boolean equals(Object other) 247 { 248 if (this == other) return true; 249 if (other == null) return false; 250 if (other.getClass() != this.getClass()) return false; 251 252 PlayerProperty o = (PlayerProperty) other; 253 254 return 255 Objects.equals(this.name, o.name) 256 && Objects.equals(this.value, o.value); 257 } 258 259 /** Generates a Hash-Code for {@code 'this'} instance */ 260 public int hashCode() 261 { 262 return 263 Objects.hashCode(this.name) 264 + Objects.hashCode(this.value); 265 } 266 } 267 268 /** Corresponds to kMediaEventTriggered */ 269 public static class PlayerEvent 270 extends BaseType 271 implements java.io.Serializable 272 { 273 /** For Object Serialization. java.io.Serializable */ 274 protected static final long serialVersionUID = 1; 275 276 public boolean[] optionals() 277 { return new boolean[] { false, false, }; } 278 279 /** <CODE>[No Description Provided by Google]</CODE> */ 280 public final Number timestamp; 281 282 /** <CODE>[No Description Provided by Google]</CODE> */ 283 public final String value; 284 285 /** 286 * Constructor 287 * 288 * @param timestamp - 289 * 290 * @param value - 291 */ 292 public PlayerEvent(Number timestamp, String value) 293 { 294 // Exception-Check(s) to ensure that if any parameters which are not declared as 295 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 296 297 if (timestamp == null) THROWS.throwNPE("timestamp"); 298 if (value == null) THROWS.throwNPE("value"); 299 300 this.timestamp = timestamp; 301 this.value = value; 302 } 303 304 /** 305 * JSON Object Constructor 306 * @param jo A Json-Object having data about an instance of {@code 'PlayerEvent'}. 307 */ 308 public PlayerEvent (JsonObject jo) 309 { 310 this.timestamp = ReadNumberJSON.get(jo, "timestamp", false, true); 311 this.value = ReadJSON.getString(jo, "value", false, true); 312 } 313 314 315 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 316 public boolean equals(Object other) 317 { 318 if (this == other) return true; 319 if (other == null) return false; 320 if (other.getClass() != this.getClass()) return false; 321 322 PlayerEvent o = (PlayerEvent) other; 323 324 return 325 Objects.equals(this.timestamp, o.timestamp) 326 && Objects.equals(this.value, o.value); 327 } 328 329 /** Generates a Hash-Code for {@code 'this'} instance */ 330 public int hashCode() 331 { 332 return 333 Objects.hashCode(this.timestamp) 334 + Objects.hashCode(this.value); 335 } 336 } 337 338 /** 339 * Represents logged source line numbers reported in an error. 340 * NOTE: file and line are from chromium c++ implementation code, not js. 341 */ 342 public static class PlayerErrorSourceLocation 343 extends BaseType 344 implements java.io.Serializable 345 { 346 /** For Object Serialization. java.io.Serializable */ 347 protected static final long serialVersionUID = 1; 348 349 public boolean[] optionals() 350 { return new boolean[] { false, false, }; } 351 352 /** <CODE>[No Description Provided by Google]</CODE> */ 353 public final String file; 354 355 /** <CODE>[No Description Provided by Google]</CODE> */ 356 public final int line; 357 358 /** 359 * Constructor 360 * 361 * @param file - 362 * 363 * @param line - 364 */ 365 public PlayerErrorSourceLocation(String file, int line) 366 { 367 // Exception-Check(s) to ensure that if any parameters which are not declared as 368 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 369 370 if (file == null) THROWS.throwNPE("file"); 371 372 this.file = file; 373 this.line = line; 374 } 375 376 /** 377 * JSON Object Constructor 378 * @param jo A Json-Object having data about an instance of {@code 'PlayerErrorSourceLocation'}. 379 */ 380 public PlayerErrorSourceLocation (JsonObject jo) 381 { 382 this.file = ReadJSON.getString(jo, "file", false, true); 383 this.line = ReadPrimJSON.getInt(jo, "line"); 384 } 385 386 387 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 388 public boolean equals(Object other) 389 { 390 if (this == other) return true; 391 if (other == null) return false; 392 if (other.getClass() != this.getClass()) return false; 393 394 PlayerErrorSourceLocation o = (PlayerErrorSourceLocation) other; 395 396 return 397 Objects.equals(this.file, o.file) 398 && (this.line == o.line); 399 } 400 401 /** Generates a Hash-Code for {@code 'this'} instance */ 402 public int hashCode() 403 { 404 return 405 Objects.hashCode(this.file) 406 + this.line; 407 } 408 } 409 410 /** Corresponds to kMediaError */ 411 public static class PlayerError 412 extends BaseType 413 implements java.io.Serializable 414 { 415 /** For Object Serialization. java.io.Serializable */ 416 protected static final long serialVersionUID = 1; 417 418 public boolean[] optionals() 419 { return new boolean[] { false, false, false, false, false, }; } 420 421 /** <CODE>[No Description Provided by Google]</CODE> */ 422 public final String errorType; 423 424 /** 425 * Code is the numeric enum entry for a specific set of error codes, such 426 * as PipelineStatusCodes in media/base/pipeline_status.h 427 */ 428 public final int code; 429 430 /** A trace of where this error was caused / where it passed through. */ 431 public final Media.PlayerErrorSourceLocation[] stack; 432 433 /** 434 * Errors potentially have a root cause error, ie, a DecoderError might be 435 * caused by an WindowsError 436 */ 437 public final Media.PlayerError[] cause; 438 439 /** Extra data attached to an error, such as an HRESULT, Video Codec, etc. */ 440 public final JsonObject data; 441 442 /** 443 * Constructor 444 * 445 * @param errorType - 446 * 447 * @param code 448 * Code is the numeric enum entry for a specific set of error codes, such 449 * as PipelineStatusCodes in media/base/pipeline_status.h 450 * 451 * @param stack A trace of where this error was caused / where it passed through. 452 * 453 * @param cause 454 * Errors potentially have a root cause error, ie, a DecoderError might be 455 * caused by an WindowsError 456 * 457 * @param data Extra data attached to an error, such as an HRESULT, Video Codec, etc. 458 */ 459 public PlayerError( 460 String errorType, int code, Media.PlayerErrorSourceLocation[] stack, 461 Media.PlayerError[] cause, JsonObject data 462 ) 463 { 464 // Exception-Check(s) to ensure that if any parameters which are not declared as 465 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 466 467 if (errorType == null) THROWS.throwNPE("errorType"); 468 if (stack == null) THROWS.throwNPE("stack"); 469 if (cause == null) THROWS.throwNPE("cause"); 470 if (data == null) THROWS.throwNPE("data"); 471 472 this.errorType = errorType; 473 this.code = code; 474 this.stack = stack; 475 this.cause = cause; 476 this.data = data; 477 } 478 479 /** 480 * JSON Object Constructor 481 * @param jo A Json-Object having data about an instance of {@code 'PlayerError'}. 482 */ 483 public PlayerError (JsonObject jo) 484 { 485 this.errorType = ReadJSON.getString(jo, "errorType", false, true); 486 this.code = ReadPrimJSON.getInt(jo, "code"); 487 this.stack = (jo.getJsonArray("stack") == null) 488 ? null 489 : RJArrIntoStream.objArr(jo.getJsonArray("stack"), null, 0, Media.PlayerErrorSourceLocation.class).toArray(Media.PlayerErrorSourceLocation[]::new); 490 491 this.cause = (jo.getJsonArray("cause") == null) 492 ? null 493 : RJArrIntoStream.objArr(jo.getJsonArray("cause"), null, 0, Media.PlayerError.class).toArray(Media.PlayerError[]::new); 494 495 this.data = jo.getJsonObject("data"); 496 } 497 498 499 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 500 public boolean equals(Object other) 501 { 502 if (this == other) return true; 503 if (other == null) return false; 504 if (other.getClass() != this.getClass()) return false; 505 506 PlayerError o = (PlayerError) other; 507 508 return 509 Objects.equals(this.errorType, o.errorType) 510 && (this.code == o.code) 511 && Arrays.deepEquals(this.stack, o.stack) 512 && Arrays.deepEquals(this.cause, o.cause) 513 && Objects.equals(this.data, o.data); 514 } 515 516 /** Generates a Hash-Code for {@code 'this'} instance */ 517 public int hashCode() 518 { 519 return 520 Objects.hashCode(this.errorType) 521 + this.code 522 + Arrays.deepHashCode(this.stack) 523 + Arrays.deepHashCode(this.cause) 524 + Objects.hashCode(this.data); 525 } 526 } 527 528 /** 529 * This can be called multiple times, and can be used to set / override / 530 * remove player properties. A null propValue indicates removal. 531 */ 532 public static class playerPropertiesChanged 533 extends BrowserEvent 534 implements java.io.Serializable 535 { 536 /** For Object Serialization. java.io.Serializable */ 537 protected static final long serialVersionUID = 1; 538 539 public boolean[] optionals() 540 { return new boolean[] { false, false, }; } 541 542 /** <CODE>[No Description Provided by Google]</CODE> */ 543 public final String playerId; 544 545 /** <CODE>[No Description Provided by Google]</CODE> */ 546 public final Media.PlayerProperty[] properties; 547 548 /** 549 * Constructor 550 * 551 * @param playerId - 552 * 553 * @param properties - 554 */ 555 public playerPropertiesChanged(String playerId, Media.PlayerProperty[] properties) 556 { 557 super("Media", "playerPropertiesChanged", 2); 558 559 // Exception-Check(s) to ensure that if any parameters which are not declared as 560 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 561 562 if (playerId == null) THROWS.throwNPE("playerId"); 563 if (properties == null) THROWS.throwNPE("properties"); 564 565 this.playerId = playerId; 566 this.properties = properties; 567 } 568 569 /** 570 * JSON Object Constructor 571 * @param jo A Json-Object having data about an instance of {@code 'playerPropertiesChanged'}. 572 */ 573 public playerPropertiesChanged (JsonObject jo) 574 { 575 super("Media", "playerPropertiesChanged", 2); 576 577 this.playerId = ReadJSON.getString(jo, "playerId", false, true); 578 this.properties = (jo.getJsonArray("properties") == null) 579 ? null 580 : RJArrIntoStream.objArr(jo.getJsonArray("properties"), null, 0, Media.PlayerProperty.class).toArray(Media.PlayerProperty[]::new); 581 582 } 583 584 585 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 586 public boolean equals(Object other) 587 { 588 if (this == other) return true; 589 if (other == null) return false; 590 if (other.getClass() != this.getClass()) return false; 591 592 playerPropertiesChanged o = (playerPropertiesChanged) other; 593 594 return 595 Objects.equals(this.playerId, o.playerId) 596 && Arrays.deepEquals(this.properties, o.properties); 597 } 598 599 /** Generates a Hash-Code for {@code 'this'} instance */ 600 public int hashCode() 601 { 602 return 603 Objects.hashCode(this.playerId) 604 + Arrays.deepHashCode(this.properties); 605 } 606 } 607 608 /** 609 * Send events as a list, allowing them to be batched on the browser for less 610 * congestion. If batched, events must ALWAYS be in chronological order. 611 */ 612 public static class playerEventsAdded 613 extends BrowserEvent 614 implements java.io.Serializable 615 { 616 /** For Object Serialization. java.io.Serializable */ 617 protected static final long serialVersionUID = 1; 618 619 public boolean[] optionals() 620 { return new boolean[] { false, false, }; } 621 622 /** <CODE>[No Description Provided by Google]</CODE> */ 623 public final String playerId; 624 625 /** <CODE>[No Description Provided by Google]</CODE> */ 626 public final Media.PlayerEvent[] events; 627 628 /** 629 * Constructor 630 * 631 * @param playerId - 632 * 633 * @param events - 634 */ 635 public playerEventsAdded(String playerId, Media.PlayerEvent[] events) 636 { 637 super("Media", "playerEventsAdded", 2); 638 639 // Exception-Check(s) to ensure that if any parameters which are not declared as 640 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 641 642 if (playerId == null) THROWS.throwNPE("playerId"); 643 if (events == null) THROWS.throwNPE("events"); 644 645 this.playerId = playerId; 646 this.events = events; 647 } 648 649 /** 650 * JSON Object Constructor 651 * @param jo A Json-Object having data about an instance of {@code 'playerEventsAdded'}. 652 */ 653 public playerEventsAdded (JsonObject jo) 654 { 655 super("Media", "playerEventsAdded", 2); 656 657 this.playerId = ReadJSON.getString(jo, "playerId", false, true); 658 this.events = (jo.getJsonArray("events") == null) 659 ? null 660 : RJArrIntoStream.objArr(jo.getJsonArray("events"), null, 0, Media.PlayerEvent.class).toArray(Media.PlayerEvent[]::new); 661 662 } 663 664 665 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 666 public boolean equals(Object other) 667 { 668 if (this == other) return true; 669 if (other == null) return false; 670 if (other.getClass() != this.getClass()) return false; 671 672 playerEventsAdded o = (playerEventsAdded) other; 673 674 return 675 Objects.equals(this.playerId, o.playerId) 676 && Arrays.deepEquals(this.events, o.events); 677 } 678 679 /** Generates a Hash-Code for {@code 'this'} instance */ 680 public int hashCode() 681 { 682 return 683 Objects.hashCode(this.playerId) 684 + Arrays.deepHashCode(this.events); 685 } 686 } 687 688 /** Send a list of any messages that need to be delivered. */ 689 public static class playerMessagesLogged 690 extends BrowserEvent 691 implements java.io.Serializable 692 { 693 /** For Object Serialization. java.io.Serializable */ 694 protected static final long serialVersionUID = 1; 695 696 public boolean[] optionals() 697 { return new boolean[] { false, false, }; } 698 699 /** <CODE>[No Description Provided by Google]</CODE> */ 700 public final String playerId; 701 702 /** <CODE>[No Description Provided by Google]</CODE> */ 703 public final Media.PlayerMessage[] messages; 704 705 /** 706 * Constructor 707 * 708 * @param playerId - 709 * 710 * @param messages - 711 */ 712 public playerMessagesLogged(String playerId, Media.PlayerMessage[] messages) 713 { 714 super("Media", "playerMessagesLogged", 2); 715 716 // Exception-Check(s) to ensure that if any parameters which are not declared as 717 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 718 719 if (playerId == null) THROWS.throwNPE("playerId"); 720 if (messages == null) THROWS.throwNPE("messages"); 721 722 this.playerId = playerId; 723 this.messages = messages; 724 } 725 726 /** 727 * JSON Object Constructor 728 * @param jo A Json-Object having data about an instance of {@code 'playerMessagesLogged'}. 729 */ 730 public playerMessagesLogged (JsonObject jo) 731 { 732 super("Media", "playerMessagesLogged", 2); 733 734 this.playerId = ReadJSON.getString(jo, "playerId", false, true); 735 this.messages = (jo.getJsonArray("messages") == null) 736 ? null 737 : RJArrIntoStream.objArr(jo.getJsonArray("messages"), null, 0, Media.PlayerMessage.class).toArray(Media.PlayerMessage[]::new); 738 739 } 740 741 742 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 743 public boolean equals(Object other) 744 { 745 if (this == other) return true; 746 if (other == null) return false; 747 if (other.getClass() != this.getClass()) return false; 748 749 playerMessagesLogged o = (playerMessagesLogged) other; 750 751 return 752 Objects.equals(this.playerId, o.playerId) 753 && Arrays.deepEquals(this.messages, o.messages); 754 } 755 756 /** Generates a Hash-Code for {@code 'this'} instance */ 757 public int hashCode() 758 { 759 return 760 Objects.hashCode(this.playerId) 761 + Arrays.deepHashCode(this.messages); 762 } 763 } 764 765 /** Send a list of any errors that need to be delivered. */ 766 public static class playerErrorsRaised 767 extends BrowserEvent 768 implements java.io.Serializable 769 { 770 /** For Object Serialization. java.io.Serializable */ 771 protected static final long serialVersionUID = 1; 772 773 public boolean[] optionals() 774 { return new boolean[] { false, false, }; } 775 776 /** <CODE>[No Description Provided by Google]</CODE> */ 777 public final String playerId; 778 779 /** <CODE>[No Description Provided by Google]</CODE> */ 780 public final Media.PlayerError[] errors; 781 782 /** 783 * Constructor 784 * 785 * @param playerId - 786 * 787 * @param errors - 788 */ 789 public playerErrorsRaised(String playerId, Media.PlayerError[] errors) 790 { 791 super("Media", "playerErrorsRaised", 2); 792 793 // Exception-Check(s) to ensure that if any parameters which are not declared as 794 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 795 796 if (playerId == null) THROWS.throwNPE("playerId"); 797 if (errors == null) THROWS.throwNPE("errors"); 798 799 this.playerId = playerId; 800 this.errors = errors; 801 } 802 803 /** 804 * JSON Object Constructor 805 * @param jo A Json-Object having data about an instance of {@code 'playerErrorsRaised'}. 806 */ 807 public playerErrorsRaised (JsonObject jo) 808 { 809 super("Media", "playerErrorsRaised", 2); 810 811 this.playerId = ReadJSON.getString(jo, "playerId", false, true); 812 this.errors = (jo.getJsonArray("errors") == null) 813 ? null 814 : RJArrIntoStream.objArr(jo.getJsonArray("errors"), null, 0, Media.PlayerError.class).toArray(Media.PlayerError[]::new); 815 816 } 817 818 819 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 820 public boolean equals(Object other) 821 { 822 if (this == other) return true; 823 if (other == null) return false; 824 if (other.getClass() != this.getClass()) return false; 825 826 playerErrorsRaised o = (playerErrorsRaised) other; 827 828 return 829 Objects.equals(this.playerId, o.playerId) 830 && Arrays.deepEquals(this.errors, o.errors); 831 } 832 833 /** Generates a Hash-Code for {@code 'this'} instance */ 834 public int hashCode() 835 { 836 return 837 Objects.hashCode(this.playerId) 838 + Arrays.deepHashCode(this.errors); 839 } 840 } 841 842 /** 843 * Called whenever a player is created, or when a new agent joins and receives 844 * a list of active players. If an agent is restored, it will receive the full 845 * list of player ids and all events again. 846 */ 847 public static class playersCreated 848 extends BrowserEvent 849 implements java.io.Serializable 850 { 851 /** For Object Serialization. java.io.Serializable */ 852 protected static final long serialVersionUID = 1; 853 854 public boolean[] optionals() 855 { return new boolean[] { false, }; } 856 857 /** <CODE>[No Description Provided by Google]</CODE> */ 858 public final String[] players; 859 860 /** 861 * Constructor 862 * 863 * @param players - 864 */ 865 public playersCreated(String[] players) 866 { 867 super("Media", "playersCreated", 1); 868 869 // Exception-Check(s) to ensure that if any parameters which are not declared as 870 // 'Optional', but have a 'null' value anyway, that a NullPointerException shall throw. 871 872 if (players == null) THROWS.throwNPE("players"); 873 874 this.players = players; 875 } 876 877 /** 878 * JSON Object Constructor 879 * @param jo A Json-Object having data about an instance of {@code 'playersCreated'}. 880 */ 881 public playersCreated (JsonObject jo) 882 { 883 super("Media", "playersCreated", 1); 884 885 this.players = (jo.getJsonArray("players") == null) 886 ? null 887 : RJArrIntoStream.strArr(jo.getJsonArray("players"), null, 0).toArray(String[]::new); 888 889 } 890 891 892 /** Checks whether {@code 'this'} equals an input Java-{@code Object} */ 893 public boolean equals(Object other) 894 { 895 if (this == other) return true; 896 if (other == null) return false; 897 if (other.getClass() != this.getClass()) return false; 898 899 playersCreated o = (playersCreated) other; 900 901 return 902 Arrays.deepEquals(this.players, o.players); 903 } 904 905 /** Generates a Hash-Code for {@code 'this'} instance */ 906 public int hashCode() 907 { 908 return 909 Arrays.deepHashCode(this.players); 910 } 911 } 912 913 914 // Counter for keeping the WebSocket Request ID's distinct. 915 private static int counter = 1; 916 917 /** 918 * Enables the Media domain 919 * 920 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 921 * {@link Ret0}></CODE> 922 * 923 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 924 * browser receives the invocation-request. 925 * 926 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 927 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 928 * {@code >} to ensure the Browser Function has run to completion. 929 */ 930 public static Script<String, JsonObject, Ret0> enable() 931 { 932 final int webSocketID = 48000000 + counter++; 933 final boolean[] optionals = new boolean[0]; 934 935 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 936 String requestJSON = WriteJSON.get( 937 parameterTypes.get("enable"), 938 parameterNames.get("enable"), 939 optionals, webSocketID, 940 "Media.enable" 941 ); 942 943 // This Remote Command does not have a Return-Value. 944 return new Script<> 945 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 946 } 947 948 /** 949 * Disables the Media domain. 950 * 951 * @return An instance of <CODE>{@link Script}<String, {@link JsonObject}, 952 * {@link Ret0}></CODE> 953 * 954 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 955 * browser receives the invocation-request. 956 * 957 * <BR /><BR />This Browser-Function <I>does not have</I> a return-value. You may choose to 958 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <JsonObject,} {@link Ret0} 959 * {@code >} to ensure the Browser Function has run to completion. 960 */ 961 public static Script<String, JsonObject, Ret0> disable() 962 { 963 final int webSocketID = 48001000 + counter++; 964 final boolean[] optionals = new boolean[0]; 965 966 // Convert Method Parameters into JSON. Build the JSON Request-Object (as a String) 967 String requestJSON = WriteJSON.get( 968 parameterTypes.get("disable"), 969 parameterNames.get("disable"), 970 optionals, webSocketID, 971 "Media.disable" 972 ); 973 974 // This Remote Command does not have a Return-Value. 975 return new Script<> 976 (webSocketID, requestJSON, VOID_RETURN.NoReturnValues); 977 } 978 979}