7

I have a button on the main tab of my apps that attempts to launch a video from an URL via second activity

I have tested with a Blank activity and successfully displayed 'Hello' when the said button is click. I then removed the 'Hello' editext and added codes to the java file as suggested in another similar post.

When the video btn is clicked, I get the message ;Can't play this video, Ok'

I have already tested the youtube link it is a valid link. Yet logcat error message include :

10-07 09:04:36.785: I/MediaPlayer(11397): path is null
10-07 09:04:36.795: D/MediaPlayer(11397): setDataSource IOException happend : 
10-07 09:04:36.795: D/MediaPlayer(11397): 
java.io.FileNotFoundException: No content provider: http://youtu.be/RFrg1xFoxeQ 

Where do I go from here ?

An XML for the second activity is as follows :-

<VideoView
    android:id="@+id/videoView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</TableLayout>

Corresponding Java file

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_serve_motion_up_together);
    String videoPath2 = "http://youtu.be/RFrg1xFoxeQ";
    VideoView videoView1 = (VideoView) findViewById(R.id.videoView1);

    videoView1.setVideoURI(Uri.parse(videoPath2));
    videoView1.setMediaController(new MediaController(this));
    videoView1.setVisibility(1);
    videoView1.bringToFront();
    videoView1.requestFocus();
    videoView1.start();       

}

Logcat

10-07 09:04:36.765: D/dalvikvm(11397): GC_CONCURRENT freed 97K, 12% free 9619K/10887K, paused 13ms+2ms, total 47ms
10-07 09:04:36.785: V/MediaPlayer(11397): constructor
10-07 09:04:36.785: V/MediaPlayer(11397): setListener
10-07 09:04:36.785: I/MediaPlayer(11397): path is null
10-07 09:04:36.795: D/MediaPlayer(11397): setDataSource IOException happend : 
10-07 09:04:36.795: D/MediaPlayer(11397): java.io.FileNotFoundException: No content provider: http://youtu.be/RFrg1xFoxeQ
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:710)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:614)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.media.MediaPlayer.setDataSource(MediaPlayer.java:929)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.widget.VideoView.openVideo(VideoView.java:235)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.widget.VideoView.access$2000(VideoView.java:51)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.widget.VideoView$6.surfaceCreated(VideoView.java:478)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.SurfaceView.updateWindow(SurfaceView.java:591)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.SurfaceView.access$000(SurfaceView.java:81)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:173)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:707)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1944)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.Choreographer.doCallbacks(Choreographer.java:555)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.Choreographer.doFrame(Choreographer.java:525)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.os.Handler.handleCallback(Handler.java:615)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.os.Handler.dispatchMessage(Handler.java:92)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.os.Looper.loop(Looper.java:137)
10-07 09:04:36.795: D/MediaPlayer(11397):   at android.app.ActivityThread.main(ActivityThread.java:4867)
10-07 09:04:36.795: D/MediaPlayer(11397):   at java.lang.reflect.Method.invokeNative(Native Method)
10-07 09:04:36.795: D/MediaPlayer(11397):   at java.lang.reflect.Method.invoke(Method.java:511)
10-07 09:04:36.795: D/MediaPlayer(11397):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
10-07 09:04:36.795: D/MediaPlayer(11397):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
10-07 09:04:36.795: D/MediaPlayer(11397):   at dalvik.system.NativeStart.main(Native Method)
10-07 09:04:36.795: D/MediaPlayer(11397): Couldn't open file on client side, trying server side
10-07 09:04:36.795: V/MediaPlayer(11397): setVideoSurfaceTexture
10-07 09:04:36.795: V/MediaPlayer(11397): MediaPlayer::setAudioStreamType
10-07 09:04:36.795: V/MediaPlayer(11397): setVideoSurfaceTexture
10-07 09:04:36.795: V/MediaPlayer(11397): prepareAsync
10-07 09:04:36.825: D/ProgressBar(11397): setProgressDrawable mProgressDrawable = null, d = android.graphics.drawable.LayerDrawable@41b6d730needUpdate = false
10-07 09:04:36.825: D/ProgressBar(11397): setProgress = 0
10-07 09:04:36.825: D/ProgressBar(11397): setProgress = 0, fromUser = false
10-07 09:04:36.825: D/ProgressBar(11397): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
10-07 09:04:36.835: W/ResourceType(11397): Failure getting entry for 0x010802c9 (t=7 e=713) in package 0 (error -75)
10-07 09:04:36.935: E/SpannableStringBuilder(11397): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
10-07 09:04:36.935: E/SpannableStringBuilder(11397): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
10-07 09:04:40.699: V/MediaPlayer(11397): message received msg=100, ext1=1, ext2=-2147483648
10-07 09:04:40.699: E/MediaPlayer(11397): error (1, -2147483648)
10-07 09:04:40.699: V/MediaPlayer(11397): callback application
10-07 09:04:40.699: V/MediaPlayer(11397): back from callback
10-07 09:04:40.699: E/MediaPlayer(11397): Error (1,-2147483648)
10-07 09:04:40.699: D/VideoView(11397): Error: 1,-2147483648
10-07 09:04:40.719: W/ResourceType(11397): Failure getting entry for 0x010802c9 (t=7 e=713) in package 0 (error -75)

TIA

CCH4ADT

Mycoola
  • 1,135
  • 1
  • 8
  • 29
CH Chee
  • 73
  • 1
  • 6
  • Yes, I have added INTERNET permission to the Android Manifest – CH Chee Oct 07 '13 at 02:10
  • Try these links with same topic. http://stackoverflow.com/questions/14211945/how-to-play-video-in-android-after-button-click http://stackoverflow.com/questions/6532875/playing-a-video-file-on-button-click – Sharath Jun 12 '15 at 06:07

2 Answers2

1

Try this:

String LINK = "http://youtu.be/RFrg1xFoxeQ";
setContentView(R.layout.mediaplayer);
VideoView videoView = (VideoView) findViewById(R.id.video);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();

i'm not sure it will work, but worth a try

Didi78
  • 247
  • 1
  • 15
0

You cannot simply put YouTube url to MediaPlayer. After all that's the link to some webpage. Android is trying to handle that, though there is no ContentProvider for that url (schema, domain etc.). If you want to play youtube videos in your application you should look into YouTube SDK for Android.

best regards, Darek