Skip to content

Commit b1fab66

Browse files
authored
Fix Event id attribute parsing (Dash-Industry-Forum#4614)
* Fix Event id attribute value parsing * Fix typings for Event.id property * index.d.ts: Define base type MediaPlayerEvent for player events
1 parent 8f35d6b commit b1fab66

File tree

2 files changed

+59
-55
lines changed

2 files changed

+59
-55
lines changed

index.d.ts

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ declare namespace dashjs {
509509
type: string;
510510
duration: number;
511511
presentationTime: number;
512-
id: string | number;
512+
id: number;
513513
messageData: string;
514514
eventStream: EventStream;
515515
presentationTimeDelta: number;
@@ -788,7 +788,7 @@ declare namespace dashjs {
788788

789789
on(type: AdaptationSetRemovedNoCapabilitiesEvent['type'], listener: (e: AdaptationSetRemovedNoCapabilitiesEvent) => void, scope?: object): void;
790790

791-
on(type: string, listener: (e: Event) => void, scope?: object): void;
791+
on(type: string, listener: (e: MediaPlayerEvent) => void, scope?: object): void;
792792

793793

794794
off(type: string, listener: (e: any) => void, scope?: object): void;
@@ -1405,7 +1405,7 @@ declare namespace dashjs {
14051405

14061406
on(type: AdaptationSetRemovedNoCapabilitiesEvent['type'], listener: (e: AdaptationSetRemovedNoCapabilitiesEvent) => void, scope?: object): void;
14071407

1408-
on(type: string, listener: (e: Event) => void, scope?: object, options?: object): void;
1408+
on(type: string, listener: (e: MediaPlayerEvent) => void, scope?: object, options?: object): void;
14091409

14101410
off(type: string, listener: (e: any) => void, scope?: object): void;
14111411

@@ -1759,31 +1759,35 @@ declare namespace dashjs {
17591759
TTML_TO_PARSE: 'ttmlToParse';
17601760
}
17611761

1762-
export interface AstInFutureEvent extends Event {
1762+
export interface MediaPlayerEvent {
1763+
type: string
1764+
1765+
}
1766+
export interface AstInFutureEvent extends MediaPlayerEvent {
17631767
type: MediaPlayerEvents['AST_IN_FUTURE'];
17641768
delay: number;
17651769
}
17661770

1767-
export interface BufferEvent extends Event {
1771+
export interface BufferEvent extends MediaPlayerEvent {
17681772
type: MediaPlayerEvents['BUFFER_EMPTY' | 'BUFFER_LOADED'];
17691773
mediaType: MediaType;
17701774
}
17711775

1772-
export interface BufferStateChangedEvent extends Event {
1776+
export interface BufferStateChangedEvent extends MediaPlayerEvent {
17731777
type: MediaPlayerEvents['BUFFER_LEVEL_STATE_CHANGED'];
17741778
mediaType: MediaType;
17751779
sender: object;
17761780
state: 'bufferStalled' | 'bufferLoaded';
17771781
streamInfo: StreamInfo;
17781782
}
17791783

1780-
export interface GenericErrorEvent extends Event {
1784+
export interface GenericErrorEvent extends MediaPlayerEvent {
17811785
type: MediaPlayerEvents['ERROR'];
17821786
error: 'capability' | 'mediasource' | 'key_session' | 'key_message';
17831787
event: string;
17841788
}
17851789

1786-
export interface DownloadErrorEvent extends Event {
1790+
export interface DownloadErrorEvent extends MediaPlayerEvent {
17871791
type: MediaPlayerEvents['ERROR'];
17881792
error: 'download';
17891793
event: {
@@ -1793,7 +1797,7 @@ declare namespace dashjs {
17931797
};
17941798
}
17951799

1796-
export interface ManifestErrorEvent extends Event {
1800+
export interface ManifestErrorEvent extends MediaPlayerEvent {
17971801
type: MediaPlayerEvents['ERROR'];
17981802
error: 'manifestError';
17991803
event: {
@@ -1804,7 +1808,7 @@ declare namespace dashjs {
18041808
};
18051809
}
18061810

1807-
export interface TimedTextErrorEvent extends Event {
1811+
export interface TimedTextErrorEvent extends MediaPlayerEvent {
18081812
type: MediaPlayerEvents['ERROR'];
18091813
error: 'cc';
18101814
event: {
@@ -1814,7 +1818,7 @@ declare namespace dashjs {
18141818
};
18151819
}
18161820

1817-
export interface MediaPlayerErrorEvent extends Event {
1821+
export interface MediaPlayerErrorEvent extends MediaPlayerEvent {
18181822
type: MediaPlayerEvents['ERROR'];
18191823
error: {
18201824
code: MediaPlayerErrors['MANIFEST_LOADER_PARSING_FAILURE_ERROR_CODE'] |
@@ -1885,57 +1889,57 @@ declare namespace dashjs {
18851889
| TimedTextErrorEvent
18861890
| MediaPlayerErrorEvent;
18871891

1888-
export interface CaptionRenderedEvent extends Event {
1892+
export interface CaptionRenderedEvent extends MediaPlayerEvent {
18891893
type: MediaPlayerEvents['CAPTION_RENDERED'];
18901894
captionDiv: HTMLDivElement;
18911895
currentTrackIdx: number;
18921896
}
18931897

1894-
export interface CaptionContainerResizeEvent extends Event {
1898+
export interface CaptionContainerResizeEvent extends MediaPlayerEvent {
18951899
type: MediaPlayerEvents['CAPTION_CONTAINER_RESIZE'];
18961900
}
18971901

1898-
export interface dvbFontDownloadAdded extends Event {
1902+
export interface dvbFontDownloadAdded extends MediaPlayerEvent {
18991903
type: MediaPlayerEvents['DVB_FONT_DOWNLOAD_ADDED'];
19001904
font: FontInfo;
19011905
}
19021906

1903-
export interface dvbFontDownloadComplete extends Event {
1907+
export interface dvbFontDownloadComplete extends MediaPlayerEvent {
19041908
type: MediaPlayerEvents['DVB_FONT_DOWNLOAD_COMPLETE'];
19051909
font: FontInfo;
19061910
}
19071911

1908-
export interface dvbFontDownloadFailed extends Event {
1912+
export interface dvbFontDownloadFailed extends MediaPlayerEvent {
19091913
type: MediaPlayerEvents['DVB_FONT_DOWNLOAD_FAILED'];
19101914
font: FontInfo;
19111915
}
19121916

1913-
export interface DynamicToStaticEvent extends Event {
1917+
export interface DynamicToStaticEvent extends MediaPlayerEvent {
19141918
type: MediaPlayerEvents['DYNAMIC_TO_STATIC'];
19151919
}
19161920

1917-
export interface FragmentLoadingCompletedEvent extends Event {
1921+
export interface FragmentLoadingCompletedEvent extends MediaPlayerEvent {
19181922
type: MediaPlayerEvents['FRAGMENT_LOADING_COMPLETED'];
19191923
request: FragmentRequest;
19201924
response: ArrayBuffer;
19211925
sender: object;
19221926
}
19231927

1924-
export interface FragmentLoadingAbandonedEvent extends Event {
1928+
export interface FragmentLoadingAbandonedEvent extends MediaPlayerEvent {
19251929
type: MediaPlayerEvents['FRAGMENT_LOADING_ABANDONED'];
19261930
streamProcessor: object;
19271931
request: object;
19281932
mediaType: MediaType;
19291933
}
19301934

1931-
export interface InbandPrftReceivedEvent extends Event {
1935+
export interface InbandPrftReceivedEvent extends MediaPlayerEvent {
19321936
type: MediaPlayerEvents['INBAND_PRFT_RECEIVED'];
19331937
streamInfo: StreamInfo;
19341938
mediaType: MediaType;
19351939
data: object
19361940
}
19371941

1938-
export interface KeyErrorEvent extends Event {
1942+
export interface KeyErrorEvent extends MediaPlayerEvent {
19391943
type: MediaPlayerEvents['KEY_ERROR'];
19401944
error: DashJSError;
19411945
}
@@ -1949,36 +1953,36 @@ declare namespace dashjs {
19491953
messageType: string;
19501954
}
19511955

1952-
export interface KeyMessageEvent extends Event {
1956+
export interface KeyMessageEvent extends MediaPlayerEvent {
19531957
type: MediaPlayerEvents['KEY_MESSAGE'];
19541958
data: KeyMessage;
19551959
}
19561960

1957-
export interface KeySessionClosedEvent extends Event {
1961+
export interface KeySessionClosedEvent extends MediaPlayerEvent {
19581962
type: MediaPlayerEvents['KEY_SESSION_CLOSED' | 'KEY_SESSION_REMOVED'];
19591963
data: string | null;
19601964
error?: string;
19611965
}
19621966

1963-
export interface KeySessionEvent extends Event {
1967+
export interface KeySessionEvent extends MediaPlayerEvent {
19641968
type: MediaPlayerEvents['KEY_SESSION_CREATED'];
19651969
data: SessionToken | null;
19661970
error?: DashJSError;
19671971
}
19681972

1969-
export interface KeyStatusesChangedEvent extends Event {
1973+
export interface KeyStatusesChangedEvent extends MediaPlayerEvent {
19701974
type: MediaPlayerEvents['KEY_STATUSES_CHANGED'];
19711975
data: SessionToken;
19721976
error?: DashJSError;
19731977
}
19741978

1975-
export interface KeySystemSelectedEvent extends Event {
1979+
export interface KeySystemSelectedEvent extends MediaPlayerEvent {
19761980
type: MediaPlayerEvents['KEY_SYSTEM_SELECTED'];
19771981
data: object | null;
19781982
error?: DashJSError;
19791983
}
19801984

1981-
export interface LicenseRequestCompleteEvent extends Event {
1985+
export interface LicenseRequestCompleteEvent extends MediaPlayerEvent {
19821986
type: MediaPlayerEvents['LICENSE_REQUEST_COMPLETE'];
19831987
data: {
19841988
sessionToken: SessionToken;
@@ -1987,110 +1991,110 @@ declare namespace dashjs {
19871991
error?: DashJSError;
19881992
}
19891993

1990-
export interface LogEvent extends Event {
1994+
export interface LogEvent extends MediaPlayerEvent {
19911995
type: MediaPlayerEvents['LOG'];
19921996
message: string;
19931997
}
19941998

1995-
export interface ManifestLoadedEvent extends Event {
1999+
export interface ManifestLoadedEvent extends MediaPlayerEvent {
19962000
type: MediaPlayerEvents['MANIFEST_LOADED'];
19972001
data: object;
19982002
}
19992003

2000-
export interface MetricEvent extends Event {
2004+
export interface MetricEvent extends MediaPlayerEvent {
20012005
type: MediaPlayerEvents['METRIC_ADDED' | 'METRIC_UPDATED'];
20022006
mediaType: MediaType;
20032007
metric: MetricType;
20042008
value: object;
20052009
}
20062010

2007-
export interface MetricChangedEvent extends Event {
2011+
export interface MetricChangedEvent extends MediaPlayerEvent {
20082012
type: MediaPlayerEvents['METRIC_CHANGED'];
20092013
mediaType: MediaType;
20102014
}
20112015

2012-
export interface OfflineRecordEvent extends Event {
2016+
export interface OfflineRecordEvent extends MediaPlayerEvent {
20132017
type: MediaPlayerEvents['OFFLINE_RECORD_FINISHED' | 'OFFLINE_RECORD_STARTED' | 'OFFLINE_RECORD_STOPPED'];
20142018
id: string;
20152019
}
20162020

2017-
export interface OfflineRecordLoademetadataEvent extends Event {
2021+
export interface OfflineRecordLoademetadataEvent extends MediaPlayerEvent {
20182022
type: MediaPlayerEvents['OFFLINE_RECORD_LOADEDMETADATA'];
20192023
madiaInfos: MediaInfo[];
20202024
}
20212025

2022-
export interface PeriodSwitchEvent extends Event {
2026+
export interface PeriodSwitchEvent extends MediaPlayerEvent {
20232027
type: MediaPlayerEvents['PERIOD_SWITCH_COMPLETED' | 'PERIOD_SWITCH_STARTED'];
20242028
toStreamInfo: StreamInfo | null;
20252029
fromStreamInfo?: StreamInfo | null;
20262030
}
20272031

2028-
export interface PlaybackErrorEvent extends Event {
2032+
export interface PlaybackErrorEvent extends MediaPlayerEvent {
20292033
type: MediaPlayerEvents['PLAYBACK_ERROR'];
20302034
error: MediaError;
20312035
}
20322036

2033-
export interface PlaybackPausedEvent extends Event {
2037+
export interface PlaybackPausedEvent extends MediaPlayerEvent {
20342038
type: MediaPlayerEvents['PLAYBACK_PAUSED'];
20352039
ended: boolean | null;
20362040
}
20372041

2038-
export interface PlaybackPlayingEvent extends Event {
2042+
export interface PlaybackPlayingEvent extends MediaPlayerEvent {
20392043
type: MediaPlayerEvents['PLAYBACK_PLAYING'];
20402044
playingTime: number | null;
20412045
}
20422046

2043-
export interface PlaybackRateChangedEvent extends Event {
2047+
export interface PlaybackRateChangedEvent extends MediaPlayerEvent {
20442048
type: MediaPlayerEvents['PLAYBACK_RATE_CHANGED'];
20452049
playbackRate: number | null;
20462050
}
20472051

2048-
export interface PlaybackSeekingEvent extends Event {
2052+
export interface PlaybackSeekingEvent extends MediaPlayerEvent {
20492053
type: MediaPlayerEvents['PLAYBACK_SEEKING'];
20502054
seekTime: number | null;
20512055
}
20522056

2053-
export interface PlaybackStartedEvent extends Event {
2057+
export interface PlaybackStartedEvent extends MediaPlayerEvent {
20542058
type: MediaPlayerEvents['PLAYBACK_STARTED'];
20552059
startTime: number | null;
20562060
}
20572061

2058-
export interface PlaybackTimeUpdatedEvent extends Event {
2062+
export interface PlaybackTimeUpdatedEvent extends MediaPlayerEvent {
20592063
type: MediaPlayerEvents['PLAYBACK_TIME_UPDATED'];
20602064
time: number | null;
20612065
timeToEnd: number;
20622066
}
20632067

2064-
export interface PlaybackWaitingEvent extends Event {
2068+
export interface PlaybackWaitingEvent extends MediaPlayerEvent {
20652069
type: MediaPlayerEvents['PLAYBACK_WAITING'];
20662070
playingTime: number | null;
20672071
}
20682072

2069-
export interface ProtectionCreatedEvent extends Event {
2073+
export interface ProtectionCreatedEvent extends MediaPlayerEvent {
20702074
type: MediaPlayerEvents['PROTECTION_CREATED'];
20712075
controller: object;
20722076
}
20732077

2074-
export interface ProtectionDestroyedEvent extends Event {
2078+
export interface ProtectionDestroyedEvent extends MediaPlayerEvent {
20752079
type: MediaPlayerEvents['PROTECTION_DESTROYED'];
20762080
data: string;
20772081
}
20782082

2079-
export interface TrackChangeRenderedEvent extends Event {
2083+
export interface TrackChangeRenderedEvent extends MediaPlayerEvent {
20802084
type: MediaPlayerEvents['TRACK_CHANGE_RENDERED'];
20812085
mediaType: MediaType;
20822086
oldMediaInfo: MediaInfo;
20832087
newMediaInfo: MediaInfo;
20842088
}
20852089

2086-
export interface QualityChangeRenderedEvent extends Event {
2090+
export interface QualityChangeRenderedEvent extends MediaPlayerEvent {
20872091
type: MediaPlayerEvents['QUALITY_CHANGE_RENDERED'];
20882092
mediaType: MediaType;
20892093
oldQuality: number;
20902094
newQuality: number;
20912095
}
20922096

2093-
export interface QualityChangeRequestedEvent extends Event {
2097+
export interface QualityChangeRequestedEvent extends MediaPlayerEvent {
20942098
type: MediaPlayerEvents['QUALITY_CHANGE_REQUESTED'];
20952099
mediaType: MediaType;
20962100
oldQuality: number;
@@ -2102,44 +2106,44 @@ declare namespace dashjs {
21022106
} | null;
21032107
}
21042108

2105-
export interface StreamInitializedEvent extends Event {
2109+
export interface StreamInitializedEvent extends MediaPlayerEvent {
21062110
type: MediaPlayerEvents['STREAM_INITIALIZED'];
21072111
streamInfo: StreamInfo;
21082112
error: Error | null;
21092113
}
21102114

2111-
export interface TextTracksAddedEvent extends Event {
2115+
export interface TextTracksAddedEvent extends MediaPlayerEvent {
21122116
type: MediaPlayerEvents['TEXT_TRACKS_ADDED'];
21132117
enabled: boolean;
21142118
index: number;
21152119
tracks: TextTrackInfo[];
21162120
}
21172121

2118-
export interface TtmlParsedEvent extends Event {
2122+
export interface TtmlParsedEvent extends MediaPlayerEvent {
21192123
type: MediaPlayerEvents['TTML_PARSED'];
21202124
ttmlString: string;
21212125
ttmlDoc: object;
21222126
}
21232127

2124-
export interface TtmlToParseEvent extends Event {
2128+
export interface TtmlToParseEvent extends MediaPlayerEvent {
21252129
type: MediaPlayerEvents['TTML_TO_PARSE'];
21262130
content: object;
21272131
}
21282132

2129-
export interface CueEnterEvent extends Event {
2133+
export interface CueEnterEvent extends MediaPlayerEvent {
21302134
type: MediaPlayerEvents['CUE_ENTER'];
21312135
id: string,
21322136
text: string,
21332137
start: number,
21342138
end: number
21352139
}
21362140

2137-
export interface CueExitEvent extends Event {
2141+
export interface CueExitEvent extends MediaPlayerEvent {
21382142
type: MediaPlayerEvents['CUE_EXIT'];
21392143
id: string,
21402144
}
21412145

2142-
export interface AdaptationSetRemovedNoCapabilitiesEvent extends Event {
2146+
export interface AdaptationSetRemovedNoCapabilitiesEvent extends MediaPlayerEvent {
21432147
type: MediaPlayerEvents['ADAPTATION_SET_REMOVED_NO_CAPABILITIES'];
21442148
adaptationSet: object;
21452149
}

src/dash/models/DashManifestModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ function DashManifestModel() {
10561056
event.duration = currentMpdEvent.duration / eventStream.timescale;
10571057
}
10581058
if (currentMpdEvent.hasOwnProperty(DashConstants.ID)) {
1059-
event.id = currentMpdEvent.id;
1059+
event.id = parseInt(currentMpdEvent.id);
10601060
} else {
10611061
event.id = null;
10621062
}

0 commit comments

Comments
 (0)