I am having a hard time to figure out how to use the Rajawali to play a 360 video. In order to achieve this, I tried every solution I could find in the Internet, but I failed.
Firstly, I used the RajawaliCardboard, and let the MainActivity extend from CardboardActivity
. At the same time, in MyRenderer
class, I let this class extend from the RajawaliCardboardRenderer
class. In MyRenderer
class, I overrided the initScene()
function:
protected void initScene() {
StreamingTexture mTexture = null;
if (externalMemoryAvailable())
{
mVideoPath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/testVideo.mp4";
try{
mPlayer = new MediaPlayer();
mPlayer.setDataSource(mVideoPath);
}catch(IllegalArgumentException e){
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
mPlayer.prepare();
} catch (IOException t) {
t.printStackTrace();
}
mTexture = new StreamingTexture("video", mPlayer);
}
Sphere sphere = createPhotoSphereWithTexture(mTexture);
getCurrentScene().addChild(sphere);
getCurrentCamera().setPosition(Vector3.ZERO);
getCurrentCamera().setFieldOfView(75);
}
private Sphere createPhotoSphereWithTexture(ATexture texture) {
Material material = new Material();
material.setColor(0);
try {
material.addTexture(texture);
} catch (ATexture.TextureException e) {
throw new RuntimeException(e);
}
Sphere sphere = new Sphere(50, 64, 32);
sphere.setScaleX(-1);
sphere.setMaterial(material);
return sphere;
}
The program can run without any error, but the screen is black and with no image.
I want to ask what should I do to improve my program, and why I should do to play video by using Rajawali. Who can help me?
I got success to play video with Rajawali.