视频播放使用Cameraview问题

时间:2017-12-11 19:20:09

标签: android video playback recording

我正在使用Cameraview捕捉视频,一旦录制完成,应用程序将全屏播放视频。然而,在我录制第一个视频后,我只看到一个黑屏。如果我重新录制并录制另一个视频,一切正常并且播放成功。我遇到的错误是:

  

E / MediaPlayer:错误(1,-2147483648)   E / MediaPlayer:isPlaying:在状态MEDIA_PLAYER_STATE_ERROR中调用

这是代码示例:

公共类VideoPreviewActivity扩展了AppCompatActivity {

FullscreenVideoLayout videoLayout;
CustomReusingDialog mCustomReusingDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_preview);
    videoLayout = (FullscreenVideoLayout) findViewById(R.id.videoview);

    videoLayout.setActivity(this);
    final Uri videoUri = getIntent().getParcelableExtra("video");
    try {
        videoLayout.setVideoURI(videoUri);

    } catch (IOException e) {
        e.printStackTrace();
    }


    videoLayout.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {

            playVideo();
        }
    });

    videoLayout.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            mCustomReusingDialog =CustomReusingDialog.newInstance(new CustomReusingDialog.Builder(VideoPreviewActivity.this, new CustomReusingDialog.OnDialogShowListener() {
                @Override
                public void onGetDialog(final Dialog mDialog, View mView) {
                    TextView uploadText =(TextView)mView.findViewById(R.id.uploadText);
                    TextView deleteText =(TextView)mView.findViewById(R.id.deleteText);

                    uploadText.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {


                            mCustomReusingDialog.dismiss();
                            if (LoginManager.isNetworkAvailable(getApplicationContext()))
                            new UploadManager(VideoPreviewActivity.this,new File(videoUri.getPath())).execute();
                            else
                                LoginManager.showMessage(getApplicationContext(),"Please Check your Network Settings!!");
                        }
                    });

                    deleteText.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {

                            mCustomReusingDialog.dismiss();
                            UploadManager.deleteFile(VideoPreviewActivity.this,new File(videoUri.getPath()));
                        }
                    });
                }
            }).setDialogLayout(R.layout.dialog_upload).setCancelAble(true));
            mCustomReusingDialog.show(getSupportFragmentManager(),"");
        }
    });
}

void playVideo() {
    if (videoLayout.isPlaying()) return;
    videoLayout.start();
}


@Override
protected void onPause() {

    super.onPause();
}
}}

0 个答案:

没有答案