Repository: flutter
Issue: [video_player] Add `VideoPlayerMediaItem` and `VideoPlayerMediaSource` data structure
Labels: p: video_player,package,c: proposal,team-ecosystem,P3,triaged-ecosystem

When I try to apply `video_player` to build my online programming education application(Coursea-like), QtClass, for all platforms, I find that the `video_player` plugin is limited in its management on media items and media source. After I studied the requirements on iOS and Android, AVPlayer and ExoPlayer, I find that it is necessary to support something like AVPlayerItem/MediaItem and AVAsset/MediaSource，so I am writing this proposal to discuss this idea with the video_player development team.

# Background

I am using the VOD services of TencentCloud as the server. It has no Flutter support and Desktop support for the client, so I am going to develop a Flutter client SDK by my own. The format of data source is HLS, which is similiar with AliCloud, Huawei Cloud, and all other VOD services I can see in China. 

As we know, the media of HLS is encrypted, but the content key is not. It is as like that you use a enhanced door, but the key of the lock is put by the door. So the original HLS is not secure in reality. VOD services of different cloud computing services use different methods to encrypt the content key for the media. For example, Tencent Cloud use DRM to make sure the right of the client at first, and then transform the HLS content key by RSA+AES.

Therefore, it is necessary to explore a API so that the HLS content key can be customized by the developers. 

# Possible Solutions

At first, I try to do this without changing the official plugin. Then I find that all the possible methods may not be workable. So I am considering add this feature by Native side. When I study the Native solutions for this problems, I find that AVPlayer and ExoPlayer are similiar to solve this problem.

For AVPlayer, the possible way is: https://stackoverflow.com/questions/39124793/playing-aes-encrypted-hls-stream-using-avplayer-ios-swift
For ExoPlayer, the possible way is https://github.com/google/ExoPlayer/issues/5362 

I am not sure whether they can work since I am not familiar with Native development, and I am going to write demos recently.

Both of them support data structure for media info. AVPlayerItem in AVPlayer or MediaItem from ExoPlayer can manage the item played by the controller. AVAsset and MediaSource can manage the original media info. 

**We can define similar data structures called `VideoPlayerMediaItem` and `VideoPlayerMediaSource` in the existing plugin, and add new API to existing `VideoPlayerController`.** This is no-breaking change on the APIs, but maybe need to rewrite some implementations, for example, the default construct can use Media class as input.

With them, it is much easier to customize the HLS content key. We just need to define a sub data structure for HLS, and explore a API so that the media info can be modified. After we get the HLS content key, we can use this API to modify the media info before playing. 

More information on the Native side:
- AVPlayerItem: https://developer.apple.com/documentation/avfoundation/avplayeritem
- AVAsset: https://developer.apple.com/documentation/avfoundation/avasset
- MediaItem: https://exoplayer.dev/media-items.html
- MediaSource: https://exoplayer.dev/media-sources.html

Notice that AVPlayerItem seems to represent a video, and MediaItem represent a piece of video. I am new to them so I am not sure whether my understanding is right.

For Web, I think the best method right now is to apply `video.js` with import_js_library(https://pub.dev/packages/import_js_library), since the native support of Web on audio and video is limited.

I have read a rejected PR on Mac support of this plugin in 2019, since the platform view is not finished. I am not sure whether it is OK at now. I am not familiar with Windows and C#, and will read more docs on that. 

# My Plan

I am going to develop a private version at first so that my project can go on. I really hope that this feature can be contributed to the official plugin, so I want to know about how this plugin and its APIs are designed, and try my best to correspond with the API design. 

In addition, I am confused that I found no git submodule settings in the Flutter plugins repository. I have no idea on how to build the CI workflow to make PRs to the official repository. 

Thanks for reading it! Hope to discuss deeply on this topic.