-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Put custom event definitions in class #7640
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*! @license | ||
* Shaka Player | ||
* Copyright 2016 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
goog.provide('shaka.Player.ErrorEvent'); | ||
|
||
goog.require('shaka.util.Error'); | ||
goog.require('shaka.util.FakeEvent'); | ||
|
||
|
||
/** | ||
* @event shaka.Player.ErrorEvent | ||
* @description Fired when a playback error occurs. | ||
* @property {string} type | ||
* 'error' | ||
* @property {!shaka.util.Error} detail | ||
* An object which contains details on the error. The error's | ||
* <code>category</code> and <code>code</code> properties will identify the | ||
* specific error that occurred. In an uncompiled build, you can also use the | ||
* <code>message</code> and <code>stack</code> properties to debug. | ||
* @extends {shaka.util.FakeEvent} | ||
* @exportDoc | ||
*/ | ||
shaka.Player.ErrorEvent = class extends shaka.util.FakeEvent { | ||
/** | ||
* @param {shaka.util.Error} error | ||
*/ | ||
constructor(error) { | ||
/** @type {!shaka.util.FakeEvent.EventName} */ | ||
const name = shaka.util.FakeEvent.EventName.Error; | ||
|
||
/** @type {Map.<string, Object>} */ | ||
const data = new Map().set('detail', error); | ||
|
||
super(name, data); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ goog.require('shaka.media.StreamingEngine'); | |
goog.require('shaka.media.TimeRangesUtils'); | ||
goog.require('shaka.net.NetworkingEngine'); | ||
goog.require('shaka.net.NetworkingUtils'); | ||
goog.require('shaka.Player.ErrorEvent'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the errors are caused by ordering and namespaces here. goog.require here will assign the ErrorEvent class to shaka.Player.ErrorEvent. Later in this file, we assign shaka.Player = class ..., overwriting what was assigned to ErrorEvent by replacing the whole shaka.Player namespace. So we might need to do something like this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, but I used |
||
goog.require('shaka.text.SimpleTextDisplayer'); | ||
goog.require('shaka.text.StubTextDisplayer'); | ||
goog.require('shaka.text.TextEngine'); | ||
|
@@ -69,19 +70,6 @@ goog.require('shaka.lcevc.Dec'); | |
goog.requireType('shaka.media.PresentationTimeline'); | ||
|
||
|
||
/** | ||
* @event shaka.Player.ErrorEvent | ||
* @description Fired when a playback error occurs. | ||
* @property {string} type | ||
* 'error' | ||
* @property {!shaka.util.Error} detail | ||
* An object which contains details on the error. The error's | ||
* <code>category</code> and <code>code</code> properties will identify the | ||
* specific error that occurred. In an uncompiled build, you can also use the | ||
* <code>message</code> and <code>stack</code> properties to debug. | ||
* @exportDoc | ||
*/ | ||
|
||
/** | ||
* @event shaka.Player.StateChangeEvent | ||
* @description Fired when the player changes load states. | ||
|
@@ -7737,9 +7725,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { | |
this.restoreDisabledVariants_(/* updateAbrManager= */ false); | ||
} | ||
|
||
const eventName = shaka.util.FakeEvent.EventName.Error; | ||
const event = shaka.Player.makeEvent_( | ||
eventName, (new Map()).set('detail', error)); | ||
const event = new shaka.Player.ErrorEvent(error); | ||
this.dispatchEvent(event); | ||
if (event.defaultPrevented) { | ||
error.handled = true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, but should this be
@export
so it can be called by apps?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I change to @export the documentation is not generated correctly.... I don't know why...