HTMLMediaElement.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/HTMLMediaElementWrapper.h>
  7. #include <LibWeb/HTML/HTMLMediaElement.h>
  8. namespace Web::HTML {
  9. HTMLMediaElement::HTMLMediaElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  10. : HTMLElement(document, move(qualified_name))
  11. {
  12. }
  13. HTMLMediaElement::~HTMLMediaElement() = default;
  14. // https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype
  15. Bindings::CanPlayTypeResult HTMLMediaElement::can_play_type(String const& type) const
  16. {
  17. // The canPlayType(type) method must:
  18. // - return the empty string if type is a type that the user agent knows it cannot render or is the type "application/octet-stream"
  19. // - return "probably" if the user agent is confident that the type represents a media resource that it can render if used in with this audio or video element
  20. // - return "maybe" otherwise. Implementers are encouraged to return "maybe" unless the type can be confidently established as being supported or not
  21. // Generally, a user agent should never return "probably" for a type that allows the codecs parameter if that parameter is not present.
  22. if (type == "application/octet-stream"sv)
  23. return Bindings::CanPlayTypeResult::Empty;
  24. // FIXME: Eventually we should return `Maybe` here, but for now `Empty` is our best bet :^)
  25. // Being honest here leads to some apps and frameworks skipping things like audio loading,
  26. // which for the time being would create more issues than it solves - e.g. endless waiting
  27. // for audio that will never load.
  28. return Bindings::CanPlayTypeResult::Empty;
  29. }
  30. }