Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 :/

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer
    
:( ok thanks for that answer :/ I suppose that I have to use Android SDK, thanks :) –  Rudy_TM Jun 14 '12 at 16:01
3  
I did it with Android :) I created a new Activity and a new Layout, and when the video finishes its playback, I start the activity that has the call to libGDX –  Rudy_TM Jun 14 '12 at 17:17
    
Nice! That was fast, I guess it wasn't too hard to do after all. –  Byte56 Jun 14 '12 at 17:18
1  
@Rudy_TM please add this as the accepted answer -- that you got around it with a new Activity. That will help others who have the same question later. –  ashes999 Jun 14 '12 at 17:34
    
It's pretty easy to write platform specific code in libgdx, so just because it doesn't support video out of the box doesn't mean it can't be done, as your answer implies. –  Matsemann Jun 14 '12 at 17:46

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>
share|improve this answer
1  
+1 Thanks for posting this answer, it will be helpful to future visitors. –  Byte56 Jun 14 '12 at 17:56
    
You are welcome :) I spent two days trying different things XD and this was the last one :P –  Rudy_TM Jun 14 '12 at 18:02
1  
It's always the last one right? I guess because you stop looking after that :p. Also congrats on nearly being done! –  Byte56 Jun 14 '12 at 18:05
    
hehe thanks :) XD –  Rudy_TM Jun 14 '12 at 18:17
1  
@G3tinmybelly in your manifest change your splash screen to the launcher activity instead of the MainActivity, –  Rudy_TM Jun 24 at 16:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.