一个玩家,但更多按钮

时间:2016-01-13 16:43:07

标签: android video-streaming android-videoview exoplayer

到目前为止,我们已经为每个流创建了一个播放器。但我说要学会正确行事。 如何制作更多按钮,每个按钮都有一个流媒体地址在同一视频视图中打开。 我认为应该有一种toString或getstring的方法。 具体来说,m3u8地址发送到另一个活动,其中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();
}

}

我想要的按钮发送&#34;地址流&#34;到videoview.but我不知道如何将一个字符串从一个活动发送到另一个活动。

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);

谢谢

1 个答案:

答案 0 :(得分:0)

正确的版本是: 进展顺利。 但是我怎样才能获得网址和其他应用程序?

  

Bundle bundle = getIntent()。getExtras();           String url = bundle.getString(&#34; url&#34;);

    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)));