0
到目前为止,我们已经为每个流创建了一个播放器。但我说要学会做对。 如何制作更多按钮,每个按钮都有一个可在同一视频视图中打开的流式地址。 我认为应该有一种方法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();
}
}
什么,我想作为一个按钮,发送“地址流”到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);
谢谢