MediaPlayer没有内容提供商错误:W / MediaPlayer:无法打开https://youtu.be/oEgpGv2CF1U:java.io.FileNotFoundException:没有内容提供商:

时间:2018-03-20 23:29:56

标签: java android android-mediaplayer java-io android-videoview

这是完整的日志:

03-20 22:49:26.953 4986-4986/? I/art: Not late-enabling -Xcheck:jni (already on)
03-20 22:49:26.955 4986-4986/? W/art: Unexpected CPU variant for X86 using defaults: x86
03-20 22:49:27.232 4986-4986/com.example.alphie.androidvideostream W/System: ClassLoader referenced unknown path: /data/app/com.example.alphie.androidvideostream-1/lib/x86
03-20 22:49:27.250 4986-4986/com.example.alphie.androidvideostream I/InstantRun: starting instant run server: is main process
03-20 22:49:27.535 4986-4986/com.example.alphie.androidvideostream W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-20 22:49:27.737 4986-5002/com.example.alphie.androidvideostream I/OpenGLRenderer: Initialized EGL, version 1.4
03-20 22:49:27.737 4986-5002/com.example.alphie.androidvideostream D/OpenGLRenderer: Swap behavior 1
03-20 22:49:27.738 4986-5002/com.example.alphie.androidvideostream W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
03-20 22:49:27.738 4986-5002/com.example.alphie.androidvideostream D/OpenGLRenderer: Swap behavior 0
03-20 22:49:27.741 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglCreateContext: 0x9f6316c0: maj 3 min 0 rcv 3
03-20 22:49:27.743 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:49:27.784 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:08.625 4986-4986/com.example.alphie.androidvideostream W/MediaPlayer: Couldn't open https://youtu.be/oEgpGv2CF1U: java.io.FileNotFoundException: No content provider: https://youtu.be/oEgpGv2CF1U
03-20 22:58:08.635 4986-4998/com.example.alphie.androidvideostream D/NetworkSecurityConfig: No Network Security Config specified, using platform default
03-20 22:58:08.666 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:09.980 4986-5049/com.example.alphie.androidvideostream E/MediaPlayer: error (1, -2147483648)
03-20 22:58:09.980 4986-4986/com.example.alphie.androidvideostream E/MediaPlayer: Error (1,-2147483648)
03-20 22:58:09.980 4986-4986/com.example.alphie.androidvideostream D/VideoView: Error: 1,-2147483648
03-20 22:58:10.069 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:10.092 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:10.131 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:10.141 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.625 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.647 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.661 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.669 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.675 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.745 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.759 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)
03-20 22:58:11.927 4986-5002/com.example.alphie.androidvideostream D/EGL_emulation: eglMakeCurrent: 0x9f6316c0: ver 3 0 (tinfo 0x9d6fe6a0)

"can't play video" error displays after hitting play button

正如您所看到的,我拥有使用权限的互联网。继承我的AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest 
       xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.example.alphie.androidvideostream">

    <uses-permission android:name="android.permission.INTERNET"/>


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" 
      />
          </intent-filter>
      </activity>
     </application>

     </manifest>

这是我的MainActivity的java:

   package com.example.alphie.androidvideostream;

   import android.app.ProgressDialog;
   import android.media.MediaPlayer;
   import android.net.Uri;
   import android.support.v7.app.AppCompatActivity;
   import android.os.Bundle;
   import android.view.View;
   import android.widget.ImageButton;
   import android.widget.ImageView;
   import android.widget.VideoView;

   public class MainActivity extends AppCompatActivity  implements 
        View.OnClickListener {

    ProgressDialog mDialog;
    VideoView videoView;
    ImageButton btnPlayPause;

     String videoURL = "https://youtu.be/oEgpGv2CF1U";

    @Override
     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);

    videoView= (VideoView)findViewById(R.id.videoView);
    btnPlayPause = (ImageButton)findViewById(R.id.btn_play_pause);
    btnPlayPause.setOnClickListener(this);
   }

    @Override
     public void onClick(View v) {
     mDialog = new ProgressDialog(MainActivity.this);
     mDialog.setMessage("Please wait...");
     mDialog.setCanceledOnTouchOutside(false);
     mDialog.show();

    try
    {
        if(!videoView.isPlaying()) {
        Uri uri = Uri.parse(videoURL);
        videoView.setVideoURI(uri);
        videoView.setOnCompletionListener(new 
          MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                btnPlayPause.setImageResource(R.drawable.ic_play);
            }
        });
    }
        else
        {
            videoView.pause();
            btnPlayPause.setImageResource(R.drawable.ic_play);
        }
    }
    catch (Exception ex )
    {

    }
    videoView.requestFocus();
    videoView.setOnPreparedListener(new 
      MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mDialog.dismiss();
            mp.setLooping(true);

            videoView.start();
            btnPlayPause.setImageResource(R.drawable.ic_pause);
        }
    });
    }
    }

正如您所看到的,我已经解析了网址并使用了uri,这样我就可以获得远程视频。有任何想法吗?感谢

1 个答案:

答案 0 :(得分:1)

https://youtu.be/oEgpGv2CF1U指向网站,而不是视频流。视频流URI的示例为 rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov

以前可以使用YouTube API获取YouTube流URI,但在2015年进行了更改。我建议您在YouTube应用中启动视频,详细信息为here