【问题标题】:Video does not play in Kindle fire. application crashing androidKindle fire 无法播放视频。应用程序崩溃的android
【发布时间】:2012-04-27 05:38:44
【问题描述】:

在我的应用程序中,我正在加载一些视频 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();

}

}

【问题讨论】:

    标签: android video-streaming kindle-fire


    【解决方案1】:

    只需使用此代码。

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-28
      • 2012-03-23
      • 1970-01-01
      相关资源
      最近更新 更多