-2

Here is the structure of the API. (JSON format).I have already parse title & subtitle from this API. But how can I parse this youtube video link and play it in android?

{
   "success": true, 
   "message": "All Contents of Nirdeshona Videos", 
    "data": [ 
        { 
            "id": 1, 
            "title": "New NVideo", 
            "sub_title": "New song",
            **"link": "https://www.youtube.com/watch?v=lecITZkWqzg",**
            "status": 1,
            "created_at": "2019-10-01 08:41:29",
            "updated_at": "2019-10-01 08:41:29"<p>
        }
    ]
}
Bruno
  • 3,872
  • 4
  • 20
  • 37
shorol
  • 790
  • 5
  • 11

2 Answers2

0

You can use videoview class to display a video. Add this to your layout to display the video

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

and then programmatically set your url and start the video.

VideoView = (VideoView)findViewById(R.id.videoView);
videoView.setVideoPath(myurl);
videoView.start();
Chris Papantonis
  • 720
  • 7
  • 18
0

If you are looking for play youtube URL video in-app then below are the library for that with the various option in player. https://github.com/PierfrancescoSoffritti/android-youtube-player

Sagar Chavda
  • 125
  • 1
  • 2
  • 12