一个播放器,但更多按钮

One player, but more buttons

到目前为止,我们已经为每个流创建了一个播放器。但我说要学会正确地做。 我怎样才能制作更多按钮,每个按钮都有一个流媒体地址,可以在同一个 videoview 中打开。 我认为应该有一种方法 toString 或 getstring。 具体来说,将m3u8地址发送到另一个activity,其中Andres m3u8被提取并放入videoview.

videoview.xml

public class MainActivity extends AppCompatActivity implements MediaPlayer.OnPreparedListener  {

protected EMVideoView emVideoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    emVideoView = (EMVideoView)findViewById(R.id.video_play_activity_video_view);
    emVideoView.setOnPreparedListener(this);

    //For now we just picked an arbitrary item to play.  More can be found at
    //https://archive.org/details/more_animation
    emVideoView.setVideoURI(Uri.parse("http://xxxxxxxxxx/xxxx/xx.m3u8"));


    //-----------------------
    if(Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
        View v = this.getWindow().getDecorView();
        v.setSystemUiVisibility(View.GONE);
    } else if(Build.VERSION.SDK_INT >= 19) {
        //for new api versions.
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);
    }


    //---------
}


@Override
public void onPrepared(MediaPlayer mp) {
    //Starts the video playback as soon as it is ready
    emVideoView.start();
}

}

我想要什么作为发送 "address streaming" 到 videoview.but 的按钮 我不知道如何制作一个字符串从一个 activity 发送到另一个。

emVideoView.setVideoURI(Uri.parse("here come the string of the button was pressed"));

这不行

>  Bundle bundle = getIntent().getExtras();
>         String url = bundle.getString("url");
> 
>         emVideoView = (EMVideoView)findViewById(R.id.video_play_activity_video_view);
>         emVideoView.setOnPreparedListener(this);
> 
>         //For now we just picked an arbitrary item to play.  More can be found at
>         //https://archive.org/details/more_animation
>         emVideoView.setVideoURI(Uri.parse(getString(R.string.url)));

按钮:

>         setContentView(R.layout.activity_main2);
>         Intent intent = new Intent(Main2Activity.this, MainActivity.class);
>         intent.putExtra("url", "http://xxxxx/xxx.m3u8");
>         startActivity(intent);

谢谢

正确的版本是: 进展顺利。 但是我怎样才能从其他应用程序中获取 url 呢?

Bundle bundle = getIntent().getExtras(); String url = bundle.getString("url");

    emVideoView = (EMVideoView)findViewById(R.id.video_play_activity_video_view);
    emVideoView.setOnPreparedListener(this);

    //For now we just picked an arbitrary item to play.  More can be found at
    //https://archive.org/details/more_animation
    emVideoView.setVideoURI(Uri.parse(url)));