Reputation: 53
So,basically I want to add multiple videos in single page .I tried adding it still its not working.there is some bug.Bcoz when I run the app there is no error.I tried experimenting with the code still its not working.I have attached my bvideos.xml and also corresponding java file.
this is my bvideos.java file
public class bvideos extends AppCompatActivity {
private VideoView videoView;
private MediaController mediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bvideos);
/* VideoView videoView = findViewById(R.id.video_view1);
videoView.setVideoPath("android.resource://"+getPackageName()+"/"+R.raw.bvideo1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);*/
Button photo = (Button) findViewById(R.id.bphoto);
photo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent y = new Intent(bvideos.this, mainpage.class);
startActivity(y);
}
});
videoView = findViewById(R.id.video_view1);
/*String fullScreen = getIntent().getStringExtra("fullScreenInd");
if("y".equals(fullScreen)){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
}*/
Uri videoUri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.bvideo1);
videoView.setVideoURI(videoUri);
mediaController = new FullScreenMediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.start();
videoView = findViewById(R.id.video_view2);
/*String fullScreen = getIntent().getStringExtra("fullScreenInd");
if("y".equals(fullScreen)){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
}*/
Uri videoUri1 = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.bvideo2);
videoView.setVideoURI(videoUri1);
mediaController = new FullScreenMediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.start();
}
}
this is my bvideos.xml file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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=".bvideos">
<LinearLayout
android:orientation="vertical"
android:background="@color/Pink"
android:weightSum="10"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2">
<TextView
android:id="@+id/TextView"
android:layout_width="950dp"
android:layout_height="550dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="5dp"
android:layout_marginBottom="0dp"
android:alpha="0.5"
android:background="@color/purple_200"
android:text=" BEGINNERS CALLIGRAPHY"
android:textAllCaps="false"
android:textColor="@color/DarkBlue"
android:textSize="25sp"
android:textStyle="bold|italic" />
<Button
android:id="@+id/bphoto"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="210dp"
android:layout_marginBottom="7dp"
android:text="PHOTOS"
android:textSize="20dp"
android:background="@color/white"
android:textColor="@color/purple_700"/>
<Button
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="52dp"
android:layout_marginBottom="7dp"
android:text="VIDEOS"
android:textSize="20dp"
android:background="@color/white"
android:textColor="@color/purple_700"/>
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp"
android:layout_margin="10dp">
<VideoView
android:id="@+id/video_view1"
android:layout_width="match_parent"
android:layout_height="242dp" />
</FrameLayout>
<TextView
android:layout_width="374dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="Brush Calligraphy Alphabets for Beginners| Basic Strokes| Lowercase Alphabets "
android:textSize="20dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_margin="10dp">
<VideoView
android:id="@+id/video_view2"
android:layout_width="match_parent"
android:layout_height="232dp" />
</FrameLayout>
<TextView
android:layout_width="374dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="How to Gothic Calligraphy Capital and Small Letters From A to Z |Blackletters Calligraphy "
android:textSize="20dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_margin="10dp">
<VideoView
android:id="@+id/video_view3"
android:layout_width="match_parent"
android:layout_height="232dp" />
</FrameLayout>
</LinearLayout>
</ScrollView>
Upvotes: 0
Views: 30
Reputation: 796
You are missing the start(); call. Try to add
videoView.start();
After
videoView.setVideoURI(uri);
Upvotes: 1