2

hello guys as of today video player 10.8 doesnt have support for included srt files in .mkv container. English is not my native language and i use a lot of .mkv with .srt inside of it. Exoplayer which video player is based on android has support out of the box via SubtitleView.

So i decided to modify video player source and added exoplayer-ui to android/build.gradle

    dependencies {
    implementation 'com.google.android.exoplayer:exoplayer-core:2.9.6'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.9.6'
    implementation 'com.google.android.exoplayer:exoplayer-dash:2.9.6'
    implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.9.6'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.6'
}

and then modified video_player-0.10.8+1/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java and added

import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.ui.SubtitleView;

added my global variables...

  private PlayerView simpleExoPlayerView;
  private SubtitleView subs;
  private SimpleExoPlayer exoPlayer;

then later on created them...

exoPlayer = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
simpleExoPlayerView = new PlayerView(context);

and finally set my player to exoplayer like i would on exoplayer native android development

surface = new Surface(textureEntry.surfaceTexture());
exoPlayer.setVideoSurface(surface);
simpleExoPlayerView.setPlayer(exoPlayer);
subs = simpleExoPlayerView.getSubtitleView();
subs.setVisibility(View.VISIBLE);

My code compiles but i get audio of the movie im playing with a BLACKSCREEN so the file is actually playing. I know my problem relies on the surface im creating and I tried a couple of things that have not work. Any ideas how i could use SubtitleView to use my srt file inside the .mkv container?

Thank you!

Adrian M Cavazos
  • 175
  • 1
  • 13

2 Answers2

0

I think you might need to add another surface for the subtitles apart.

Lucas van Dongen
  • 9,328
  • 7
  • 39
  • 60
  • that plugin is incomplete. take advantage of calling native code for each os and use the player you like the most natively and bypass flutter and flutter plugin. – Adrian M Cavazos Dec 16 '20 at 18:04
0

As of this day flutter continues with limited video support. Flutter was designed to be multiplatform and this is the main problem, video on diferent platforms is handled diferently, video codecs, subtitle support, hardware limitations(chipsets) on phones and tablets also play a major problem to flutters video plugin.

So far I have dealt with this problem by using platform channel on flutter and this is also limited to some platforms like android and ios. You could also use a web video player and hack flutter to make your videos work. Theres no simple answer, stop losing time and get it to work by hacking your way around and not using the video plugin.

Adrian M Cavazos
  • 175
  • 1
  • 13