0

在我的应用程序中,我加载了一些视频 mp4 文件,它可以在平板电脑和其他安卓设备上播放,但是当我尝试在 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();

}

}

4

2 回答 2

2

只需使用此代码。

 Intent browserIntent = new Intent(Intent.ACTION_VIEW,
             Uri.parse(url));
      startActivity(browserIntent);
于 2012-05-09T13:47:50.723 回答
0

Kindle fire 是亚马逊特有的图书阅读应用程序。如果要在其中安装任何应用程序,则需要先root 设备。尝试安装 Daroon Player 的 apk(可在他们的网站上获得),然后安装您的应用程序。它会起作用的。

于 2012-04-27T06:01:01.990 回答