2012-04-27 97 views
0

在我的應用程序中我加載了一些視頻mp4文件,它在平板電腦和其他Android設備上播放,但是當我嘗試在kindle火上播放相同的視頻時,應用程序崩潰。任何建議請。請看看我的代碼視頻不能在Kindle中播放。應用程序崩潰android

public class VideoPlayer extends Activity { 

private VideoView vidPlayer; 
private ImageView ivPlayerBG; 
private MediaController mc; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.videoplayer); 
    Utils.setOrientation(this); 
    vidPlayer = (VideoView) findViewById(R.id.vidPlayer); 
    ivPlayerBG = (ImageView) findViewById(R.id.ivPlayerBG); 
    mc = new MediaController(this); 
    vidPlayer.setMediaController(mc); 
    vidPlayer.setFocusable(true); 
    mc.show(0); 
    //onControllerHide(); 

    AudioManager audioMan = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 

    if (audioMan.getStreamVolume(AudioManager.STREAM_MUSIC) <= 0) { 
     Toast.makeText(this, "volume is set to mute", Toast.LENGTH_LONG) 
       .show(); 
    } 

    Log.v("totla memory play", "" + Runtime.getRuntime().totalMemory()); 
    Log.v("HEAP_SIZE ", "" + Debug.getNativeHeapAllocatedSize()); 

    Boolean isAudio = getIntent().getExtras().getBoolean("audio"); 
    if (null != isAudio && isAudio) { 
     ivPlayerBG.setBackgroundResource(R.drawable.ic_launcher); 
    } 

    Uri videoUrl = Uri.parse(Utils.getSDCardPath(getIntent().getExtras() 
      .getString("url"))); // Uri.parse(Utils.getSDCardPath("Media/video.mp4")); 
    Log.v("log" + videoUrl.getPath(), "logv"); 
    playVideo(videoUrl); 

} 

public void onControllerHide() { 
    mc.hide(); 
} 

public void playVideo(Uri videouri) { 
    try { 
     vidPlayer.setVideoURI(videouri); 
     vidPlayer.requestFocus(); 
     vidPlayer.start(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 

@Override 
protected void onDestroy() { 
    super.onDestroy(); 

} 

}

回答

0

的Kindle Fire是亞馬遜的特定圖書閱讀應用。如果你想在其中安裝任何應用程序,你需要首先root the device。嘗試安裝Daroon Player(在他們的網站上提供)apk然後安裝你的應用程序。它會工作。

+0

我的設備已經紮根,並安裝Android應用程序安靜長回...我會得到玩家 – cavallo 2012-04-27 06:09:54

+0

你會得到它在Daroon的網站。 http://www.androidzoom.com/android_applications/media_and_video/daroon-player_bdqdv.html – 2012-04-27 06:11:51

+0

也是這個https://play.google.com/store/apps/details?id=com.daroonplayer.dsplayer&feature=search_result – 2012-04-27 06:17:28

2

只需使用此代碼即可。

Intent browserIntent = new Intent(Intent.ACTION_VIEW, 
      Uri.parse(url)); 
     startActivity(browserIntent);