Is there a way to play videos with LibGDX?
I want to put a video as my splash screen in Android, but I dont want to use the Android SDK, because I am using LibGDX and I am almost finished :/
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityIs there a way to play videos with LibGDX?
I want to put a video as my splash screen in Android, but I dont want to use the Android SDK, because I am using LibGDX and I am almost finished :/
Playing video with LibGDX has been defined as out of scope for the project. So no, you cannot play videos using LibGDX.
This does not preclude the possibility of writing code specific to Android to play videos though. It just means your application won't maintain the portability of LibGDX.
As Byte56 said, in libGDX you cannot play videos :( so i did this:
I created a new activity "SplashScreen"
public class SplashScreen extends Activity implements OnCompletionListener
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
String fileName = "android.resource://"+ getPackageName() +"/raw/video";
VideoView vv = (VideoView) this.findViewById(R.id.surface);
vv.setVideoURI(Uri.parse(fileName));
vv.setOnCompletionListener(this);
vv.start();
}
@Override
public void onCompletion(MediaPlayer mp)
{
// TODO Auto-generated method stub
Intent intent = new Intent(this, libgdx.class);
startActivity(intent);
finish();
}
}
In the "onCompletion" method, I use the intent to call my new activity where the "initialize" call for the libGDX engine to work
And a new layout for the videoView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<VideoView
android:id="@+id/surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
</VideoView>
</LinearLayout>
This is the way to play: libname is "indiespot-media-0.8.09.jar" which you can get here.
How to use:
player = new MoviePlayer(videoFile);
Texure playerTexture = new Texture(
player.movie.width(),
player.movie.height(),
Pixmap.Format.RGBA8888) {
@Override
public void bind() {
Gdx.gl.glBindTexture(0, player.textureHandle);
}
};
playerTexture
as usual texture