media-kit / media-kit

A cross-platform video player & audio player for Flutter & Dart.
https://github.com/media-kit/media-kit
MIT License
937 stars 140 forks source link

Playing a local video file instead of web address #811

Closed caneroncu closed 1 month ago

caneroncu commented 1 month ago

Hello,

Using the plugin for iOS and Android

By any chance, do you know how to load local files via media_kit? I am trying to load a local file (an asset) on my phone using a statement like this:

_player.open(Media('assets/intro_screens/12.mp4'));

and adding my assets to my pubspec.yaml like this

assets: # Add assets from the images directory to the application. - assets/images/ - assets/intro_screens/intro_screens/

However it does not load and only black screen appears. However, if I do it via a web address it works but I need to do it using a local file. Can you help me out?

Kind regards

abdelaziz-mahdy commented 1 month ago

use asset:///$asset your asset will be asset:///assets/intro_screens/12.mp4

abdelaziz-mahdy commented 1 month ago

for more logs use

player =
       Player(configuration: PlayerConfiguration(logLevel: MPVLogLevel.debug));
   player.stream.log.listen((event) {
     print("log $event");
   });

to see if the file is loaded correctly

alperefesahin commented 1 month ago

await player.open(Media('asset:///assets/map.mp4'));

this one worked for me, thanks!