NathanaelA / nativescript-exoplayer

Please use: https://github.com/nstudio/nativescript-plugins/
27 stars 36 forks source link

HLS v4 on Android infers content type incorrectly #50

Closed alexgritton closed 4 years ago

alexgritton commented 4 years ago

When trying to use an HLS v4 streaming url, this chooses the wrong content type, and the video never starts playing. I've narrowing this down problem down to this function, and instead of it returning HLS it returns DASH. I've set this to always return HLS in my case and the video starts playing normally.

private _detectTypeFromSrc(uri: any): number { let type = com.google.android.exoplayer2.util.Util.inferContentType(uri); switch (type) { case 0: return this.TYPE.DASH; case 1: return this.TYPE.SS; case 2: return this.TYPE.HLS; default: return this.TYPE.OTHER; } }

According to this issue https://github.com/google/ExoPlayer/issues/4060 inferContentType is not exhaustive, and can return the wrong content type in some instances.

Because of the limitations of inferContentType, my suggestion would be adding another property called contentType, that overrides the inferred type if set. This would allow developers to work around these edge case file types that don't get inferred properly.

alexgritton commented 4 years ago

I submitted a pull request for this.