QCMediaPlayer媒体播放器不存在

时间:2019-04-09 16:32:41

标签: android video-streaming android-videoview

从URL流式传输视频时,我的videoView中存在此问题 我想在Videoview中流式传输rstp链接,我的屏幕上出现错误,例如“无法播放此视频”,而在logcat中出现如下错误

QCMediaPlayer媒体播放器不存在     04-09 21:45:11.855 326-1960 /? E / NuPlayer:NuPlayer无法创建代理客户端实例     04-09 21:45:11.865 326-4215 /? E / IMediaHTTPConnection:请求65536,得到4294967295     04-09 21:45:11.865 326-4215 /? E / NuCachedSource2:源返回错误-1008,还剩10次重试

以下是我的代码,我尝试了很多链接,并且能够下载并观看它。

public class FragmentSports extends FragmentChannels {
    private String videoURL = "http://www.androidbegin.com/tutorial/AndroidCommercial.3gp";
    // Declare some variables
    private ProgressDialog pDialog;
    VideoView videoview;
    public static FragmentSports newInstance() {
        FragmentSports fragment = new FragmentSports();
        return fragment;
    }

       @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
            View v = inflater.inflate(R.layout.sports_fragment, container, false);
           VideoView videoView = v.findViewById(R.id.vv_live);


           videoview = (VideoView) v.findViewById(R.id.vv_live);
           // Execute StreamVideo AsyncTask
           new StreamVideo().execute();
           return v;
        }

    private class StreamVideo extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            // Create a progressbar
            pDialog = new ProgressDialog(getActivity());
            // Set progressbar title
            pDialog.setTitle("Android Video Streaming Tutorial");
            // Set progressbar message
            pDialog.setMessage("Buffering...");
            pDialog.setIndeterminate(false);
            // Show progressbar
            pDialog.show();

        }
        @Override
        protected Void doInBackground(Void... params) {
            // TODO Auto-generated method stub
            return null;
        }
        @Override
        protected void onPostExecute(Void args) {

            try {
                // Start the MediaController
                MediaController mediacontroller = new MediaController(
                        getContext());
                mediacontroller.setAnchorView(videoview);
                // Get the URL from String VideoURL
                Uri video = Uri.parse(videoURL);
                videoview.setMediaController(mediacontroller);
                videoview.setVideoURI(video);

                videoview.requestFocus();
                videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                    // Close the progress bar and play the video
                    public void onPrepared(MediaPlayer mp) {
                        pDialog.dismiss();
                        videoview.start();
                    }
                });
            } catch (Exception e) {
                pDialog.dismiss();
                Log.e("Error", e.getMessage());
                e.printStackTrace();
            }

        }

    }


}

0 个答案:

没有答案