我必须在Android版本4.2.2中使用GiraffePlayer播放高清视频并且播放效果非常好, 但是当我播放两个视频时,我遇到问题,而当我播放第二个视频时只播放一个视频,然后它会停止第一个视频。 因此,如果有人能够了解如何使用GiraffePlayer同时播放两个视频,请告诉我。
我使用过的代码和库:
compile' com.github.tcking:giraffeplayer2:0.1.12'
编译' com.github.tcking:ijkplayer-x86:0.8.4'
MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "/storage/emulated/0/Download/720p.mp4";
VideoView videoView = (VideoView) findViewById(R.id.video_view);
videoView.setVideoPath(url).getPlayer().start();
String url1 = "/storage/emulated/0/Download/360.mp4";
VideoView videoView2 = (VideoView) findViewById(R.id.video_view2);
videoView2.setVideoPath(url1).getPlayer().start();
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ic.lcd.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<tcking.github.com.giraffeplayer2.VideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="210dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<tcking.github.com.giraffeplayer2.VideoView
android:id="@+id/video_view2"
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_alignParentBottom="true"/>
</LinearLayout>