在我的应用程序中我加载一些视频mp4文件,它在平板电脑和其他Android设备上播放,但当我尝试在kindle fire上播放相同的视频时应用程序崩溃。请给我任何建议。请查看我的代码
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 :(得分:2)
只需使用此代码。
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
startActivity(browserIntent);
答案 1 :(得分:0)
Kindle fire是亚马逊特定的书籍阅读应用程序。如果要在其中安装任何应用程序,则需要先root the device。尝试安装Daroon Player的apk(可在他们的网站上找到),然后安装你的应用程序。它会工作。