3
votes

Android, videoView ne peut pas ouvrir cette vidéo Vidéo en ligne

J'ai utilisé videoView pour lire un fichier mp4 à partir d'Internet, mais il ne peut pas lire cette vidéo tout le temps. Voici mon code:

2019-03-15 09:11:49.867 26152-26152/com.uitest W/com.uitest: JIT profile information will not be recorded: profile file does not exits.
2019-03-15 09:11:49.873 26152-26152/com.uitest I/chatty: uid=10049(com.uitest) identical 10 lines
2019-03-15 09:11:49.873 26152-26152/com.uitest W/com.uitest: JIT profile information will not be recorded: profile file does not exits.
2019-03-15 09:11:49.915 26152-26152/com.uitest I/InstantRun: starting instant run server: is main process
2019-03-15 09:11:50.088 26152-26152/com.uitest D/OpenGLRenderer: Skia GL Pipeline
2019-03-15 09:11:50.168 26152-26170/com.uitest I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
2019-03-15 09:11:50.168 26152-26170/com.uitest I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
2019-03-15 09:11:50.169 26152-26170/com.uitest I/OpenGLRenderer: Initialized EGL, version 1.4
2019-03-15 09:11:50.169 26152-26170/com.uitest D/OpenGLRenderer: Swap behavior 2
2019-03-15 09:11:50.184 26152-26170/com.uitest D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
2019-03-15 09:11:54.270 26152-26152/com.uitest W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@2732a9
2019-03-15 09:11:54.477 26152-26170/com.uitest D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
2019-03-15 09:11:54.521 26152-26152/com.uitest W/MediaPlayer: Couldn't open http://vfx.mtime.cn/Video/2019/02/08/mp4/190208204943376259.mp4: java.io.FileNotFoundException: No content provider: http://vfx.mtime.cn/Video/2019/02/08/mp4/190208204943376259.mp4
2019-03-15 09:11:54.521 26152-26152/com.uitest V/MediaHTTPService: MediaHTTPService(android.media.MediaHTTPService@f158d8c): Cookies: null
2019-03-15 09:11:54.578 26152-26165/com.uitest V/MediaHTTPService: makeHTTPConnection: CookieManager created: java.net.CookieManager@b0e0224
2019-03-15 09:11:54.580 26152-26165/com.uitest V/MediaHTTPService: makeHTTPConnection(android.media.MediaHTTPService@f158d8c): cookieHandler: java.net.CookieManager@b0e0224 Cookies: null
2019-03-15 09:11:54.594 26152-26165/com.uitest D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2019-03-15 09:11:55.136 26152-26170/com.uitest W/libEGL: EGLNativeWindowType 0x95077008 disconnect failed
2019-03-15 09:12:24.841 26152-26166/com.uitest E/MediaPlayerNative: error (1, -2147483648)
2019-03-15 09:12:24.842 26152-26152/com.uitest E/MediaPlayer: Error (1,-2147483648)
2019-03-15 09:12:24.842 26152-26152/com.uitest D/VideoView: Error: 1,-2147483648
2019-03-15 09:12:25.037 26152-26170/com.uitest D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000

Il pourrait bien fonctionner dans mon émulateur, mais pas avec mon appareil Android. Et ma targetSdkVersion et compileSdkVersion sont 28, l'API de mon appareil Android est Android 28, mon API d'émulateur est 23

et le logcat comme suit:

Uri uri = Uri.parse("http://vfx.mtime.cn/Video/2019/02/08/mp4/190208204943376259.mp4");
videoView.setVideoURI(uri);
videoView.setOnPreparedListener(createOnPreparedListener());

private MediaPlayer.OnPreparedListener createOnPreparedListener(){
        return new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mp.start();
            }
        };
    }


0 commentaires

3 Réponses :


0
votes

Tout supprimer et utiliser simplement

 videoView.setVideoPath(videoUrl);

        videoView.start();


1 commentaires

cela prendra un certain temps pour la mise en mémoire tampon



0
votes

Veuillez essayer ceci

 mVideoViewIntro = findViewById(R.id.video_view_intro);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(mVideoViewIntro);
    mVideoViewIntro.setMediaController(mediaController);
    mVideoViewIntro.setVideoURI(Uri.parse("YOURURLGOESHERE"));
    mVideoViewIntro.start();
    mImageViewClose.setOnClickListener(v -> onBackPressed());

    mVideoViewIntro.setOnPreparedListener(mp -> {
        mp.start();
        mp.setOnVideoSizeChangedListener((mp1, arg1, arg2) -> {
            mProgressBar.setVisibility(View.GONE);
            mp1.start();
        });
    });


0 commentaires

1
votes

Je pourrais résoudre ce problème en ajoutant ceci à mon manifeste android: usesCleartextTraffic = "true":

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>

Pour plus d'informations, veuillez vérifier ce answear https://stackoverflow.com/a/50834600/3433232


0 commentaires