在 Android 中从视频视图移动到场景
我正在为我的应用程序使用 andengine 。我正在使用 OnAreaTouched 方法显示特定场景的视频。我已经在视频视图上实现了 ontouchlistener 。我想通过视频视图的 onTouch 方法移动到下一个场景。但我无法移动到下一个场景,甚至 engine.setScene() 也不起作用。我在这里发布我的代码以供参考。
private void videoscreen(){
setContentView(R.layout.video);
final VideoView vv=(VideoView) findViewById(R.id.VideoView);
String uri = "android.resource://" + getPackageName() + "/" + R.raw.video1;
vv.setVideoURI(Uri.parse(uri));
vv.setMediaController(new MediaController(this));
vv.start();
vv.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
vv.stopPlayback();
engine.setScene(scene);
return true;
}
});
}
protected Scene scene(){
Scene scene=new Scene();
scene.setBackgroundEnabled(false);
scene.setTouchAreaBindingEnabled(true);
mBgTr = BitmapTextureAtlasTextureRegionFactory.createFromAsset(main.mBg, main.getApplicationContext(), "Common/bg.png", 0, 0);
slideBg = new Sprite(0, 0, mBgTr);
scene.attachChild(slideBg);
return scene;
}
I am using andengine for my app. I am showing video from particular scene using OnAreaTouched method. I have implemented ontouchlistener on video view. I wanted to move to next scene on onTouch method of video view. But i am unable to move to the next scene,even engine.setScene() not working. I am posting my code here for referance.
private void videoscreen(){
setContentView(R.layout.video);
final VideoView vv=(VideoView) findViewById(R.id.VideoView);
String uri = "android.resource://" + getPackageName() + "/" + R.raw.video1;
vv.setVideoURI(Uri.parse(uri));
vv.setMediaController(new MediaController(this));
vv.start();
vv.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
vv.stopPlayback();
engine.setScene(scene);
return true;
}
});
}
protected Scene scene(){
Scene scene=new Scene();
scene.setBackgroundEnabled(false);
scene.setTouchAreaBindingEnabled(true);
mBgTr = BitmapTextureAtlasTextureRegionFactory.createFromAsset(main.mBg, main.getApplicationContext(), "Common/bg.png", 0, 0);
slideBg = new Sprite(0, 0, mBgTr);
scene.attachChild(slideBg);
return scene;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须重新设置 RenderSurfaceView。
您可以查看 AndEngine 如何调用
setContentView
并执行相同的操作来返回引擎(不推荐),或者只是为视频视图创建一个新的 Activity(推荐)。You must set the RenderSurfaceView back.
You can either take a look how AndEngine calls
setContentView
and do the same to return the engine (Not recommended), or just create a new activity for the video view (Recommended).