如何在Vitamio中启用字幕(SRT)支持?

时间:2013-07-10 15:11:15

标签: android api subtitle srt

我确实尝试过所有内容,但我无法让我的SubRip-subtitles在Vitamio中运行。是否因为在播放视频时不支持字幕?我想知道。英语Vitamio支持很糟糕。

以下是我的想法:

    public class StreamVideoActivity extends FragmentActivity implements OnSubtitleUpdateListener {
        //Variables
        VideoView streamingVideo;
        TextView subtitleText;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_stream_video);

            subtitleText = (TextView) findViewById(R.id.subText);
            streamingVideo = (VideoView) findViewById(R.id.videoView);

            //BLABLABLABLA

            streamingVideo.setVideoPath(fileUrl);
            streamingVideo.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
            streamingVideo.setMediaController(mediaController);
            streamingVideo.setBufferSize(512);
            streamingVideo.setOnPreparedListener(new OnPreparedListener(){

                @Override
                public void onPrepared(MediaPlayer arg0) {
                    streamingVideo.setSubPath(subtitleFile.getPath());
                    streamingVideo.setSubShown(true);
                    streamingVideo.setSubEncoding(null);
                    streamingVideo.setSubTrack(MediaPlayer.SUBTITLE_EXTERNAL);
                    streamingVideo.setOnSubtitleUpdateListener(this);
                    streamingVideo.start();
                }
            }
        }
        @Override
        public void onSubtitleUpdate(final String arg0) {
            if (arg0 != null) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        subtitleText.setText(arg0);
                    }
                });
            }
        }

        @Override
        public void onSubtitleUpdate(byte[] arg0, int arg1, int arg2) {
            // TODO Auto-generated method stub

        }
    }

1 个答案:

答案 0 :(得分:0)

您可以下载VitamioBundle,vitamio-sample有一个样本用于字幕支持。