我很難弄清楚如何使用Rajawali播放360視頻。爲了達到這個目的,我嘗試了所有可以在互聯網上找到的解決方案,但是我失敗了。如何使用RajawaliVR或Rajawali播放360視頻
首先,我使用Rajawali紙板,讓MainActivity從CardboardActivity
延伸。同時,在MyRenderer
班上,我讓這個班從RajawaliCardboardRenderer
班擴展而來。在MyRenderer
類,我overrided的initScene()
功能:
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;
}
該程序可以在沒有任何錯誤運行,但屏幕是黑色的,沒有圖像。
我想問我該怎麼做才能改善我的節目,以及爲什麼我應該通過使用Rajawali播放視頻。誰能幫我?
我已經通過使用Unity + CardBoard + EasyMovieTexture實現了它。我會嘗試你的解決方案,非常感謝你! –
偉大的工作!你如何動態改變視頻紋理? –
你的意思是改變下一個視頻嗎? –