I have created a VR video player using Google Cardboard Android SDK and Rajawali VR.
I want to add control buttons like play, pause, stream like a normal video player.
How can I implement this?
Create a button UI inside the Sphere where your 360 video is textured. Try this code:
Material playBtnM = new Material();
playBtnM.setColorInfluence(0);
try {
//place the button picture in "res/drawable-nodpi/"
playBtnM.addTexture(new Texture("playBtn", R.drawable.play));
} catch(TextureException e) {
e.printStackTrace();
}
Plane playBtn;
playBtn = new Plane(1, 1, 8, 8);
playBtn.setScale(-1);
playBtn.setMaterial(playBtnMaterial);
playBtn.setPosition(0, 0, -2);
playBtn.setAlpha(0);
this.getCurrentScene().addChild(playBtn);
You can use Cube or other primitves rather than Plane in Rajawali to map your texture to.
Create your own way to trigger the button. For example, using a focus point at the center. If the focus point is inside the button, then the button is triggered.
Notify the video player. Call start(), pause() or stop() method of MediaPlayer to control playback when the button is triggered.