-
Notifications
You must be signed in to change notification settings - Fork 134
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: add an option to play without audio or video if audio or video failed #1624
base: dev
Are you sure you want to change the base?
Conversation
724b4a3
to
5a073f9
Compare
relates to #1602 |
Shouldn't it be "tracks" here?
Doesn't it break the API this way? Its complex but it changes the default behavior on which some applications may rely? Wouldn't it be safer to default it to |
Yes I think I should default it to "error" instead. |
I have updated it. |
ef25c83
to
4b6acd7
Compare
As this adds a similar logic in the TrackStore + Manifest + Init, and as the manifest is more or less intended to just regroup metadata, I'm wondering if it would not be easier to follow if that option was mainly handled by a part of the What do you think? |
5e29ebe
to
dc7bfe7
Compare
Automated performance checks have been performed on commit Tests results✅ Tests have passed. Performance tests 1st run outputNo significative change in performance for tests:
If you want to skip performance checks for latter commits, add the |
1b34a61
to
d11562d
Compare
Automated performance checks have been performed on commit Tests results✅ Tests have passed. Performance tests 1st run outputNo significative change in performance for tests:
If you want to skip performance checks for latter commits, add the |
Automated performance checks have been performed on commit Tests results✅ Tests have passed. Performance tests 1st run outputNo significative change in performance for tests:
If you want to skip performance checks for latter commits, add the |
doc/api/Loading_a_Content.md
Outdated
tracks are playable. | ||
|
||
- If neither the audio nor video tracks are playable, an error will be thrown regardless | ||
of this setting. |
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.
Prettier did not seem to include the end of this sentence in the same list element (it misses indentation) - I don't know how it will render once transformed into HTML
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.
Also, maybe we should tell here the error code in question, so that application developers can know how to handle those without having to reproduce it.
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.
Because this is inside a
I have added the error code
doc/api/Loading_a_Content.md
Outdated
tracks are playable. | ||
|
||
- If neither the audio nor video tracks are playable, an error will be thrown regardless | ||
of this setting. |
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.
also here
|
||
- `id`: (`"string"`): The ID of the period. | ||
|
||
- `start`: (`"number"`): The start time of the period. |
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.
First there's a line break between list elements then there's not :O, we must decide!
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.
fixed
doc/api/Player_Events.md
Outdated
|
||
- `start`: (`"number"`): The start time of the period. | ||
- `end`: (`"number" | undefined`): The end time of the period. (may be `undefined` if no | ||
end time is set). |
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.
More generally, end
is also undefined
for live contents where there's no end for now, which is a frequent case.
src/manifest/classes/period.ts
Outdated
{ tracks: undefined }, | ||
); | ||
} | ||
hasSupportedMedia[ttype] = hasSupportedAdaptations; |
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.
Is hasSupportedMedia
used at all here?
@@ -153,7 +153,7 @@ export default function generateManifestParser( | |||
return Promise.reject(cancelSignal.cancellationError); | |||
} | |||
const warnings: IPlayerError[] = []; |
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.
From what I understand, warnings
isn't used anywhere anymore? We could remove it from the transports
API
// there is no track of this type to select. | ||
log.debug( | ||
`TS: The period does not have adaptation for ${ttype} there is no track to choose`, | ||
); |
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.
I'm wondering if having this debug log for each Period without some text AdaptationSet at each update wouldn't be too much
if ( | ||
adaptationsForType.every((adapt) => adapt.supportStatus.hasSupportedCodec === false) | ||
) { | ||
const firstPlayableAdaptation = findFirstPlayableAdaptation(period, ttype); |
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.
I don't get it, how could firstPlayableAdaptation
be set to anything other than undefined
here, didn't we just check that no adaptation of that type is supported in that Period?
What possibility am I missing?
{ tracks: undefined }, | ||
); | ||
|
||
if ( |
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.
It seems that in this particular case, we do not have the noPlayableTrack
event.
Is that wanted? From reading the API documentation, I would think that this case would lead to that event.
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.
Though after doing more thinking, it seems that sending the noPlayableTrack
event here might not work because we might not have advertised the Period yet through a newAvailablePeriods
event, no?
textTypeInfo.storedSettings = storedSettings; | ||
textTypeInfo.dispatcher?.updateTrack(storedSettings); | ||
} | ||
return; |
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.
By returning early, we don't send the trackUpdate
event
if (this._isDisposed) { | ||
return; // Someone disposed the `TracksStore` on the previous side-effect | ||
} | ||
this.trigger("error", noRepErr); |
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.
Note: I don't remember if we exchanged about this, but this means that we throw even if the application e.g. disable the video track on a noPlayableTrack
event for video content - where it could theoretically play under the wanted settings.
I'm OK with this behavior, it's just to check whether we're on the same page on this.
if (isNullOrUndefined(typeInfo) || typeInfo.storedSettings !== storedSettings) { | ||
return; | ||
} | ||
typeInfo.dispatcher?.updateTrack(storedSettings); |
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.
Aren't we in the risk of setting null
for the video track when there's already no audio track and vice-versa here? Shouldn't we also check for the NO_AUDIO_VIDEO_TRACKS
error?
}; | ||
const audioAdaptation = getSupportedAdaptations(period, "audio")[0] as | ||
| IAdaptationMetadata | ||
| undefined; |
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.
The as
is just to indicate that the value may be undefiined
?
There may be better ways no? The problem I see with as
is possible bugs if we make code changes while trusting TypeScript a little too much to save our back
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.
Yes it's just to indicate it could be undefined
as typescript does not know that accessing through indexing can be undefined. I found a more clever way to handle it.
Note that using Array.at() correctly infer the type but this is ES2022 so I didn't use it there.
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.
I'm wondering if TypeScript automatically translate at
calls
if (textTypeInfo !== undefined) { | ||
const storedSettings = null; | ||
textTypeInfo.storedSettings = storedSettings; | ||
textTypeInfo.dispatcher?.updateTrack(storedSettings); |
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.
No need to do this if it was already null
before no?
| undefined; | ||
if (audioAdaptation === undefined) { | ||
trackStorePeriod.audio.storedSettings = null; | ||
this.onNoPlayableRepresentation(period, "audio"); |
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.
/!\ I'm under the impression that this method may lead to noPlayableTrack
events which communicate about Periods not yet advertised through newAvailablePeriods
events, so the application is generally not supposed to know about them in the order of events we had until now :/
12adc49
to
e9717dc
Compare
e9717dc
to
40f9dfa
Compare
Currently, the player throws an error if either all audio or all video tracks are not playable. This PR introduces two new options, onAudioTrackNotPlayable and onVideoTrackNotPlayable, to the loadVideo method. These options allow the player to continue playback even when all audio or video tracks are not playable. In such cases, the content will play without audio or video, respectively, instead of failing.
API
loadVideo(options)
options object has two more keys:onAudioTrackNotPlayable
:"continue"
or"error"
. Default if not set:"continue"
onVideoTrackNotPlayable
:"continue"
or"error"
. Default if not set:"continue"
Usage
Example
https://codesandbox.io/p/sandbox/amazing-pare-kdf65f