2014-12-02 4 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?우리는 어떻게 안드로이드 4.2.2에서 비디오 뷰의 자막을 추가 할 수 있습니까?

답변

0

기본 Android 미디어 플레이어를 사용하지 마십시오. 나는 ijkPlayer를 사용하며, Vlc lib, Vitamo 및 기타 많은 미디어 플레이어가 android에 있습니다. 내가 언급 한 모든 플레이어가 자막 기능을 추가 할 수 있는지 확실하지 않습니다.

+0

고맙습니다. 당신은 안드로이드에 대해 더 많은 플레이어를 제안 할 수 있습니까? –

+0

많은 플레이어가 있습니다. 그냥 구글. 나는 쉬운 해결책을 찾지 못했습니다. 거의 모든 플레이어는 * .so 파일을 만들기 위해 NDK 도구와 적어도 리눅스 VM이 필요합니다. – Alpha

+0

Vitamio는 좋은 옵션이며 구현하기 쉽습니다. Videoview에 추가 기능을 제공합니다. –