alexmercerind / dart_vlc

Flutter bindings to libVLC.
GNU Lesser General Public License v2.1
512 stars 136 forks source link

How to handle error when play broken files #324

Open Q-Bug4 opened 2 years ago

Q-Bug4 commented 2 years ago

Describe the feature you'd like I wanna know how can I check if a video file can be played or not.

Additional context When I played a video file which was broken, there was no exception thrown but message in the console: (Meanwhile it is able to play other normal video files)

[00007f83b401e1a0] mjpeg demux error: data shortage
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f83b4077780] moov atom not found
[00007f83b401e1a0] avformat demux error: Could not open ///home/kael/tmp/x.mp4: Unknown error 1094995529
[00007f84302f61c0] main input error: 您的输入无法被打开
[00007f84302f61c0] main input error: VLC 无法打开 MRL「file://///home/kael/tmp/x.mp4」。详情请检查日志。

And I tried try catch but seems nothing happened:

try {
      var media = Media.file(file);
      player.open(media);
} catch (e) {
      Util.showInfoDialog(context, 'Vlc Error', e.toString());
}

Operating system:

Other details:

Thanks in advance!

alexmercerind commented 1 year ago

I will recommend listening to the Player.errorStream for events. It is the only solution for now.

https://github.com/alexmercerind/dart_vlc/blob/ca4ee5f025617b64a5ebc83085ec1206ad5b4969/ffi/lib/src/player.dart#L84-L85