2014-12-02 72 views
0
protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.videoview_main); 
     MediaPlayer mp=new MediaPlayer(); 
     videoview = (VideoView) findViewById(R.id.VideoView); 
     } 
     pDialog = new ProgressDialog(VideoViewActivity.this); 
     // Set progressbar title 
     pDialog.setTitle("Android Video Streaming Tutorial"); 
     // Set progressbar message 
     pDialog.setMessage("Buffering..."); 
     pDialog.setIndeterminate(false); 
     pDialog.setCancelable(false); 
     // Show progressbar 
     pDialog.show(); 

     try { 
      MediaController mediacontroller = new MediaController(
        VideoViewActivity.this); 
      mediacontroller.setAnchorView(videoview); 
          Uri video = Uri.parse(VideoURL); 
      videoview.setMediaController(mediacontroller); 
      videoview.setVideoURI(video); 
      InputStream i = getApplicationContext().getResources().openRawResource(R.raw.test); 
      videoview.addSubtitleSource(i ,MediaFormat.createSubtitleFormat("text/srt",Locale.ENGLISH.getLanguage())); 

      videoview.start(); 


     } catch (Exception e) { 
      Log.e("Error", e.getMessage()); 
      e.printStackTrace(); 
     } 

     videoview.requestFocus(); 



    } 


} 

The above code is showing java.lang.NoSuchMethodError: when i try to run it on android 4.2 version. Is their is any other way so that i can use subtitles in video view in android?我們如何在android 4.2.2的視頻視圖中添加字幕?

回答

0

請勿使用默認的Android媒體播放器。我使用ijkPlayer,還有Vlc lib,Vitamo和許多其他Android媒體播放器。不確定是否每個我提到的玩家都有字幕添加功能。

+0

Thanx先生你可以建議更多的球員爲Android – 2015-01-07 01:44:23

+0

有很多。只是谷歌它。我沒有找到一些簡單的解決方案。幾乎每個玩家都需要NDK工具和至少linux虛擬機來構建* .so文件。 – Alpha 2015-01-07 09:39:59

+0

Vitamio是一個不錯的選擇,易於實現。它爲您的Videoview提供了額外的功能。 – 2015-07-21 05:55:43

相關問題