abdelaziz-mahdy / flutter_meedu_videoplayer

Cross-Platform Video Player for flutter
https://abdelaziz-mahdy.github.io/flutter_meedu_videoplayer/
MIT License
132 stars 69 forks source link

DRM support #137

Closed GitGud31 closed 11 months ago

GitGud31 commented 11 months ago

My company is building an OTT app with Flutter for a big client, but till now we couldn't find a video player for Flutter that supports DRM (Android, iOS and Web). Does flutter_meedu_videoplayer support DRM videos ?

abdelaziz-mahdy commented 11 months ago

What is drm videos?

GitGud31 commented 11 months ago

DRM stands for Digital Rights Management, it's a protection solution that helps content producers protect their video streams with top-grade encryption. Different Platforms propose different SDKs for DRM video protection that you can read about here: Apple's, Google's, Microsoft's.

I hope this helps

abdelaziz-mahdy commented 11 months ago

If video_player can handle it it will work, if mpv can handle it media_kit should handle it

I use both, you can switch between them

GitGud31 commented 11 months ago

I don't think they do, but i'll give it a try and let you know, cheers!

GitGud31 commented 11 months ago

EDIT: better description

Here's the dataSource schema for the video

{
        "name": "HD (cenc)",
        "uri": "https://VIDEO_MPD_LINK_HERE.mpd",
        "drm_scheme": "widevine",
        "drm_license_uri": "DRM_LICENSE_LINK_HERE"
},

there's no place/attribute to where to put the drm_license_uri to be sent and it's required to stream the video because without it, we get this error:

D/EGL_emulation(24551): app_time_stats: avg=168.50ms min=4.62ms max=4474.78ms count=28
[flutter_meedu_videoplayer] Fit is BoxFit.fill
I/ExoPlayerImpl(24551): Init 378b8e0 [ExoPlayerLib/2.18.7] [emulator64_x86_64_arm64, sdk_gphone64_x86_64, Google, 32]
[flutter_meedu_videoplayer] Last fit used was fill
[flutter_meedu_videoplayer] Fit is BoxFit.fill
D/EGL_emulation(24551): app_time_stats: avg=11.49ms min=3.96ms max=106.89ms count=52
D/EGL_emulation(24551): app_time_stats: avg=6.54ms min=3.39ms max=19.49ms count=59
D/EGL_emulation(24551): app_time_stats: avg=16.60ms min=9.83ms max=23.45ms count=61
E/ExoPlayerImplInternal(24551): Playback error
E/ExoPlayerImplInternal(24551):   com.google.android.exoplayer2.ExoPlaybackException: Source error
E/ExoPlayerImplInternal(24551):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:644)
E/ExoPlayerImplInternal(24551):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:616)
E/ExoPlayerImplInternal(24551):       at android.os.Handler.dispatchMessage(Handler.java:102)
E/ExoPlayerImplInternal(24551):       at android.os.Looper.loopOnce(Looper.java:201)
E/ExoPlayerImplInternal(24551):       at android.os.Looper.loop(Looper.java:288)
E/ExoPlayerImplInternal(24551):       at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal(24551):   Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
E/ExoPlayerImplInternal(24551):       at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:413)
E/ExoPlayerImplInternal(24551):       at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:263)
E//ExoPlayerImplInternal(24551):       at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
E/ExoPlayerImplInternal(24551):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1005)
E/ExoPlayerImplInternal(24551):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
E/ExoPlayerImplInternal(24551):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal(24551):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal(24551):       at java.lang.Thread.run(Thread.java:920)
[flutter_meedu_videoplayer] PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null)
[flutter_meedu_videoplayer] Fit is BoxFit.fill

Notice the 'Caused by' error (403), since we didn't ask to check for DRM the license.

abdelaziz-mahdy commented 11 months ago

Can't these values get sent as http headers?

GitGud31 commented 11 months ago

I don't think so no, I'll try to make a demo app with drm content links so you can test it if you can/want, because the links I have to sensitive and I can't share them.

hkarmoush commented 11 months ago

A solution that's worth looking into is using native code, there are multiple video players with DRM support out of the box on either iOS/Android maybe look into Bitmovin/Theo and integrating it with your flutter app using method channels.

I have used Bitmovin for a VOD platform and it was an enjoyable experience in their documentation.

abdelaziz-mahdy commented 11 months ago

Sadly I can't have the time to implement those, so I can't provide support to it if its not supported by video_player or media_kit

If you are able to implement those I recommend creating a package with your work, which will help people greatly with the same requirements.

And If you do create one , let me know, I may be able to integrate it into my package

hkarmoush commented 11 months ago

@zezo357 I totally agree this is a time consuming task, my comment was more tailored as an advice for what's possible for @GitGud31

abdelaziz-mahdy commented 11 months ago

@zezo357 I totally agree this is a time consuming task, my comment was more tailored as an advice for what's possible for @GitGud31

Yes and thank you very much for your help, I was just explaining my side since I will not be able to implement it, just to keep the hopes in check from my side 😢

GitGud31 commented 11 months ago

I am open to try and help Implement DRM Support and configuration if you're interested. (I work full time, I can only work on this on the weekends)

abdelaziz-mahdy commented 11 months ago

I am open to try and help Implement DRM Support and configuration if you're interested. (I work full time, I can only work on this on the weekends)

Sadly you will have to ask media_kit for it, since I can't and don't handle the video playback itself media_kit and video_player does it.