MediaError.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. */
  21. /**
  22. * This class contains information about any Media errors.
  23. */
  24. /*
  25. According to :: http://dev.w3.org/html5/spec-author-view/video.html#mediaerror
  26. We should never be creating these objects, we should just implement the interface
  27. which has 1 property for an instance, 'code'
  28. instead of doing :
  29. errorCallbackFunction( new MediaError(3,'msg') );
  30. we should simply use a literal :
  31. errorCallbackFunction( {'code':3} );
  32. */
  33. var _MediaError = window.MediaError;
  34. if(!_MediaError) {
  35. window.MediaError = _MediaError = function(code, msg) {
  36. this.code = (typeof code != 'undefined') ? code : null;
  37. this.message = msg || ""; // message is NON-standard! do not use!
  38. };
  39. }
  40. _MediaError.MEDIA_ERR_NONE_ACTIVE = _MediaError.MEDIA_ERR_NONE_ACTIVE || 0;
  41. _MediaError.MEDIA_ERR_ABORTED = _MediaError.MEDIA_ERR_ABORTED || 1;
  42. _MediaError.MEDIA_ERR_NETWORK = _MediaError.MEDIA_ERR_NETWORK || 2;
  43. _MediaError.MEDIA_ERR_DECODE = _MediaError.MEDIA_ERR_DECODE || 3;
  44. _MediaError.MEDIA_ERR_NONE_SUPPORTED = _MediaError.MEDIA_ERR_NONE_SUPPORTED || 4;
  45. // TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below.
  46. // as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes
  47. _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4;
  48. module.exports = _MediaError;