yqritc / Android-ScalableVideoView

Android Texture VideoView having a variety of scale types like the scale types of ImageView such as fitCenter, centerCrop, centerTopCrop and more
Apache License 2.0
1.09k stars 223 forks source link

is Pobile to play video from url? #19

Open fedesenmartin opened 8 years ago

fedesenmartin commented 8 years ago

I want to play video from url,as is inherit from MediaPlayer I suppose it cans,has something specifilc?

Im not able to play it

Thanks!

ghost commented 8 years ago
try {
            scalableTextureView.setDataSource(context, videoUri);
            scalableTextureView.prepareAsync(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mp) {
                    scalableTextureView.start();
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
fansangg commented 8 years ago

@Sam-kh

try { Uri uri = Uri.parse(url); scalableVideoView.setDataSource(UIUtils.getContext(),uri); scalableVideoView.setLooping(true); scalableVideoView.prepareAsync(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { scalableVideoView.start(); } });

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

05-16 03:39:58.818 28479-28479/com.budong.gif E/MediaPlayer: setDataSource: IOException! uri=http://ac-MjIf6Nns.clouddn.com/9805633f518e60b9. java.io.FileNotFoundException: No content provider: http://ac-MjIf6Nns.clouddn.com/9805633f518e60b9. at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1108) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:946) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:873) at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1003) at android.media.MediaPlayer.setDataSource(MediaPlayer.java:968) at com.yqritc.scalablevideoview.ScalableVideoView.setDataSource(ScalableVideoView.java:148) at com.budong.gif.utils.VideoManager.startVideo(VideoManager.java:35) at com.budong.gif.activity.MainActivity.showView(MainActivity.java:494) at com.budong.gif.activity.MainActivity.access$500(MainActivity.java:87) at com.budong.gif.activity.MainActivity$1.done(MainActivity.java:319) at com.budong.gif.protocol.GifProtocols$1.done(GifProtocols.java:32) at com.budong.gif.protocol.GifProtocols$1.done(GifProtocols.java:28) at com.avos.avoscloud.FunctionCallback.internalDone0(FunctionCallback.java:45) at com.avos.avoscloud.AVCallback$1.run(AVCallback.java:12) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:199) at android.app.ActivityThread.main(ActivityThread.java:5755) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:982) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:777)

why?????

ghost commented 8 years ago

@fansangg The video file which you're trying to play does not exist.

fansangg commented 8 years ago

@Sam-kh Uri uri = Uri.parse(url); scalableVideoView.setDataSource(UIUtils.getContext(),uri);

it's not video file,it's a uri. but the video can play correctly.

ghost commented 8 years ago

@fansangg Your uri is http://ac-mjif6nns.clouddn.com/9805633f518e60b9 and it should be pointing to a video which you wanna play. Now if you open the uri in your browser, it shows a json document which contains an error with message "Document not found". Also you have a java.io.FileNotFoundException in your log which means there's no video to play.

Provide a valid uri then it should work.

fansangg commented 8 years ago

@Sam-kh "http://ac-MjIf6Nns.clouddn.com/9805633f518e60b9." This uri is valid, you can play video in a browser, can also play in the app. but Logcat shows error FileNotFoundException

yqritc commented 8 years ago

@fansangg Sorry for late response. I believe u are missing internet permission in manifest. Add the following line in ur manifest and retry playing.

<uses-permission android:name="android.permission.INTERNET" />
AminJun commented 6 years ago

Could you solve it? I have the same problem.

ashfaaaa commented 6 years ago

@fansangg @AminJun did you guys found a solution ? what i found is if i use this in onCreate method it works fine. but same link if i get it from firebase it gives me and error


       try {
            Log.e("Get Data Count ", " its here ");
            Uri urii = Uri.parse("http://clips.vorwaerts-gmbh.de/VfE_html5.mp4");
            mVideoView.setDataSource(SquareCameraActivity.this, urii);
            mVideoView.setVolume(0, 0);
            mVideoView.setLooping(true);
            mVideoView.prepare(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mp) {
                    mVideoView.start();
                }
            });
        } catch (IOException ioe) {
            //ignore
            Log.e("Get Data Count ", String.valueOf(ioe));
        }```