title: Android fragment - can't play this video
body: <p>I would like to play a video from website by using fragment in android. However, when I run the app, error were showing stating that </p>
  
  <blockquote>
    <p>Can't play this video</p>
  </blockquote>
  
  <p>The url is valid and there's no error in coding. Can someone help me?</p>
  
  <p><code>VideoFragment.java</code></p>
  
  <pre><code>public class VideoFragment extends Fragment {
  VideoView videoview;
  
  String VideoURL="https://www.youtube.com/watch?v=pzWfjOaAbcE";
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
  
  View  v = inflater.inflate(R.layout.videoview_fragment, container, false);
  VideoView videoView=(VideoView)v.findViewById(R.id.VideoView);
  
  MediaPlayer player = MediaPlayer.create(getActivity(), Uri.parse(VideoURL));
  
  
  Uri video = Uri.parse(VideoURL);
  
  
  MediaController mediaController = new MediaController(getActivity());
  mediaController.setAnchorView(videoView);
      videoView.setVideoURI(video);
      videoView.requestFocus();
      videoView.setMediaController(mediaController);
      videoView.start();
  return  v;
  }}
  </code></pre>
  
  <p><code>videoview_fragment.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
      &lt;VideoView
      android:id="@+id/VideoView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Logcat:</p>
  
  <pre><code>12-14 19:57:08.948: E/MediaPlayer-JNI(24690): QCMediaPlayer mediaplayer NOT present
  12-14 19:57:08.948: D/MediaPlayer(24690): Couldn't open file on client side, trying server side
  12-14 19:57:08.953: D/MediaHTTPConnection(24690): filterOutInternalHeaders: key=User-Agent, val= SonyD6503 Build/23.4.A.1.232 stagefright/1.2 (Linux;Android 5.1.1)
  12-14 19:57:08.953: D/MediaHTTPConnection(24690): filterOutInternalHeaders: key=x-wap-profile, val= http://uaprof.sonymobile.com/D6503R2321.xml
  12-14 19:57:08.953: D/MediaHTTPConnection(24690): proxy null port 0
  12-14 19:57:10.072: E/MediaPlayer(24690): error (1, -2147483648)
  12-14 19:57:10.073: D/MediaPlayer(24690): create failed:
  12-14 19:57:10.073: D/MediaPlayer(24690): java.io.IOException: Prepare failed.: status=0x1
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.media.MediaPlayer._prepare(Native Method)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.media.MediaPlayer.prepare(MediaPlayer.java:1188)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.media.MediaPlayer.create(MediaPlayer.java:881)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.media.MediaPlayer.create(MediaPlayer.java:854)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.media.MediaPlayer.create(MediaPlayer.java:833)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at com.example.eventstory.VideoFragment.onCreateView(VideoFragment.java:25)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.app.Fragment.performCreateView(Fragment.java:2053)
   12-14 19:57:10.073: D/MediaPlayer(24690):  at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:894)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.app.BackStackRecord.run(BackStackRecord.java:834)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.os.Handler.handleCallback(Handler.java:739)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.os.Handler.dispatchMessage(Handler.java:95)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.os.Looper.loop(Looper.java:211)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at android.app.ActivityThread.main(ActivityThread.java:5373)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at java.lang.reflect.Method.invoke(Native Method)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at java.lang.reflect.Method.invoke(Method.java:372)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
  12-14 19:57:10.073: D/MediaPlayer(24690):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
  12-14 19:57:10.093: I/Choreographer(24690): Skipped 68 frames!  The application may be doing too much work on its main thread.
  12-14 19:57:10.126: I/VideoView(24690): Open Video
  12-14 19:57:10.129: E/MediaPlayer-JNI(24690): QCMediaPlayer mediaplayer NOT present
   12-14 19:57:10.132: I/VideoView(24690): SetDataSource
   12-14 19:57:10.133: D/MediaPlayer(24690): Couldn't open file on client side, trying server side
   12-14 19:57:10.139: D/MediaHTTPConnection(24690): filterOutInternalHeaders: key=User-Agent, val= SonyD6503 Build/23.4.A.1.232 stagefright/1.2 (Linux;Android 5.1.1)
   12-14 19:57:10.139: D/MediaHTTPConnection(24690): filterOutInternalHeaders: key=x-wap-profile, val= http://uaprof.sonymobile.com/D6503R2321.xml
   12-14 19:57:10.140: D/MediaHTTPConnection(24690): proxy null port 0
  </code></pre>