1

I'm Creating an application with Horizontal RecyclerView. I've successfully added the items and managed to attach click handler for each items. But I am able to see only one video which i specified as the url of the Video. I want to play different videos with respect to the url of that record when clicked. Below is my code:

import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

public class DetailsActivity extends AppCompatActivity {
    VideoView vidView;
    TextView description;
    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_details);
        vidView=(VideoView) findViewById(R.id.myVideo);
        description=(TextView)findViewById(R.id.tv_description_detail);
        Intent intent = getIntent();

        // String video_links = intent.getStringExtra("video_details");
        String desc_detail = intent.getStringExtra("description_details");
        int image = intent.getIntExtra("image",0);
        String vidAddress = "https://archive.org/download/ksnn_compilation_master_the_internet/ksnn_compilation_master_the_internet_512kb.mp4";
        Uri vidUri = Uri.parse(vidAddress);
        vidView.setVideoURI(vidUri);

        MediaController vidControl = new MediaController(this);

        vidControl.setAnchorView(vidView);

        vidView.setMediaController(vidControl);
        vidView.setOnPreparedListener(new
                 MediaPlayer.OnPreparedListener()  {
                 @Override
                       public void onPrepared(MediaPlayer mp) {
                       Log.i(TAG, "Duration = " +
                       vidView.getDuration());
                       }
                 });
        vidView.start();
        description.setText(desc_detail);

    }
}
Irshu
  • 8,248
  • 8
  • 53
  • 65
ZKhan
  • 37
  • 5
  • Share your error log with different video playing? – Ramesh sambu Dec 27 '17 at 05:26
  • 1
    Just pass the url in bundle to next activity. read [how-do-i-pass-data-between-activities](https://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android-application). – ADM Dec 27 '17 at 05:26
  • no i am playing only one video when click on every item and now and i am asking about how to play different videos when clicked on each item. – ZKhan Dec 27 '17 at 05:32
  • where is multiple URL for play different video? – Hemant Parmar Dec 27 '17 at 05:41
  • https://www.rmp-streaming.com/media/bbb-360p.mp4 This is the second url i want to test so i want to implement these two urls for each item to play llike one link for one item and second link for second i9tem – ZKhan Dec 27 '17 at 06:04

1 Answers1

0

you have to use recycler view adapter for this.create a pojo of your three values.then create a recycler view adapter and on recycler view item click play the video by getting the url of that position