- Version
- 1.0.0
- License
- MIT
- Requires
- DomSmith
- Source
- Notifications.js, line 12
Constructor
new Notifications(player, parent)
Members
private #config :Object
Holds the instance configuration for this component.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
showFileOnError
|
boolean | optional | false | Shows the media file name in errors. |
showMessageOnError
|
boolean | optional | false | Show additional message in errors, useful for debugging. |
- Type
- Object
- Source
- Notifications.js, line 19
private #player :Player
Reference to the main player instance.
- Type
- Player
- Source
- Notifications.js, line 28
private #dom :DomSmith
The DomSmith instance used to create the notification UI.
- Type
- DomSmith
- Source
- Notifications.js, line 34
private #contentDom :DomSmith
The DomSmith instance holding the actual notification content.
- Type
- DomSmith
- Source
- Notifications.js, line 40
private #subscriptions :Array<number>
Holds tokens of subscriptions to player events, for later unsubscribe.
- Type
- Array<number>
- Source
- Notifications.js, line 46
private #notifications :Array<Notifications~notificationData>
Internal queue of notifications to show.
- Type
- Array<Notifications~notificationData>
- Source
- Notifications.js, line 52
private #state :string
The current state of the notification: "hidden", "visible", or "hiding".
- Type
- string
- Source
- Notifications.js, line 58
private #timeOutId :number
Holds the ID of the timeout which causes the notification to autohide.
- Type
- number
- Source
- Notifications.js, line 64
Methods
private #show(notifyDataArgopt)
Shows a notification (or queues it if there is another active). If no argument is given, tries to show the first queued item.
| Name | Type | Attributes | Description |
|---|---|---|---|
notifyDataArg |
Notifications~notificationData | optional |
The notification data to show. |
- Source
- Notifications.js, line 104
private #hide()
Hides the notification, usually after a certain timeout Notifications might also be hidden if the players recovers from an error state, for example by loading another media file or if the video is playable again.
- Listens
- media/canplay
- media/play
- Source
- Notifications.js, line 209
private #hidden()
private #onMediaError(event)
Handler for media/error events. This tries to map the error code to a more user-friendly message and triggers a notification with the error details.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
event |
Object |
The error event object.
|
- Listens
- media/error
- Source
- Notifications.js, line 246
private #onDataError(message)
Handler listing to data errors, invokes the show() method to display an appropriate notification.
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
message |
Object |
A message Object.
|
- Listens
- data/error
- Source
- Notifications.js, line 299
private #onNotification(notifyData, topic)
Handler listing to notification events, invokes the show() method to display an appropriate notification.
| Name | Type | Description |
|---|---|---|
notifyData |
Notifications~notificationData |
The data and configuration Object. |
topic |
string |
Publisher topic. |
- Listens
- notification
- Source
- Notifications.js, line 316
destroy()
This method removes all events, subscriptions and DOM nodes created by this component.
- Source
- Notifications.js, line 339
Type Definitions
notificationData
Represents the data used to show a notification in the UI.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
type
|
string | optional | The notification type (e.g., "error", "info", etc.). |
||||||||
title
|
string | optional | The title of the notification. |
||||||||
message
|
string | optional | The main message body of the notification. |
||||||||
messageSecondary
|
string | optional | Additional / secondary message text. |
||||||||
content
|
HTMLElement | optional | Optional custom DOM node to display in the notification. |
||||||||
options
|
Object | optional | Additional options.
|
- Type
- Object
- Source
- Notifications.js, line 351
Events
notification
This event triggeres a notification to be displayed.
| Name | Type | Description |
|---|---|---|
notificationData |
Notifications~notificationData |
Notification data to display. |
- Listeners
- Notifications#onNotification
- Source
- Notifications.js, line 363