Closed mnn closed 4 years ago
It might be that your video is unsupported by the native android player. Could you try to play the video through your gallery?
Yeah, you are correct. Android can't play theora files, back to square one - finding free codec/container combination which runs on desktop and also on Android. BTW isn't somewhere a list of supported formats and codecs?
You can find which formats android natively supports here: http://developer.android.com/guide/appendix/media-formats.html
Unfortunately, there is no easy way to support different formats in android at the moment. Though ffmpeg could be compiled for android as well, it would not be good enough for most purposes because it would not be hardware accelerated. The desktop can support videoformats different from theora. However, because of licensing, the precompiled binaries do not. If you have gone through the licenses and found a format that you can use, and that is supported by ffmpeg, you can include it in the ffmpeg compile.
In a project I worked on which used gdx-video, we used different asset packs for the different platforms, containing different videos for each platform. This made sense for quality as well.
Thanks for responding.
In a project I worked on which used gdx-video, we used different asset packs for the different platforms, containing different videos for each platform. This made sense for quality as well.
I am considering exactly what you're describing - different assets per platform. It's probably the best solution.
I had this problem too and could not get it to work no matter what file format I used. I did some debugging and found that the FileHandle you give to VideoPlayerAndroid.play() does indeed exists. But when futher down in same method:
try {
if (fHandle.type() == FileType.Classpath || (fHandle.type() == FileType.Internal && !fHandle.file().exists())) {
AssetManager assets = ((AndroidApplication)Gdx.app).getAssets();
AssetFileDescriptor descriptor = assets.openFd(fHandle.name());
player.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
} else {
player.setDataSource(fHandle.file().getAbsolutePath());
}
player.setSurface(new Surface(videoTexture));
player.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
It throws and exception saying FileNotFound...
AssetFileDescriptor descriptor = assets.openFd(fHandle.name());
player.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
Is the problem since it does not consider the path only the file name. I then rearranged my assets so that the video files are in the root folder and now it works. Thought it might help someone else that can not get it to work using subfolders for their video files.
Is the problem since it does not consider the path only the file name. I then rearranged my assets so that the video files are in the root folder and now it works.
Have you been able to change the library to consider the whole path? So using fHandle.path(), instead of .name()? If so, did it fix it? Did it break something?
I personally am very busy at the moment unfortunately, so I probably don't have time to fix this. It does look like a serious bug.
Yes indeed changing
AssetFileDescriptor descriptor = assets.openFd(fHandle.name());
to
AssetFileDescriptor descriptor = assets.openFd(fHandle.path());
worked for using subfolders
I have a following snippet in Java which works on desktop, but fails on Android.
FileHandle fileHandle = Gdx.files.internal("data/converted.mp4");
System.out.println("Exists?: " + fileHandle.exists());
videoPlayer.play(fileHandle);
Notice the video file exists: true followed by java.io.FileNotFoundException: converted.mp4.
I can play that video without problems using an android activity with videoView attached.
Any help would be appretiated.
I have a following snippet in Scala which works on desktop, but fails on Android 4.1 (Genymotion emulator):
Log from failure (it doesn't crash the app, just skips playing the video):
Notice the
video file exists: true
followed byjava.io.FileNotFoundException: a.ogg
, I'm very confused :confused:.Could this be related?
Any help would be appreciated.