I have tried days to play a Video that been put in SDCard or somewhere user can access by the File Browser. I made a UMG with a TextBox and Button. When the button is clicked, I use “Open File” node to play the video that the path is from TextBox. But it always return False. No matter what Path I give.
I look into LogCat There is an log “Failed to set data source for file /…/DCIM/Camera/test.mp4”. I flow the code and find in file “AndroidMediaPlayer.cpp” line 312.
if (!JavaMediaPlayer->SetDataSource(FileRootPath, FileOffset, FileSize))
{
UE_LOG(LogAndroidMedia, Warning, TEXT("Failed to set data source for file %s"), *FilePath);
return false;
}
And I find it call a Java Function in file “Mediaplayer14.java” named “setDataSource” and got a false.
public boolean setDataSource(
String moviePath, long offset, long size)
throws IOException,
java.lang.InterruptedException,
java.util.concurrent.ExecutionException
{
audioTracks.clear();
videoTracks.clear();
try
{
File f = new File(moviePath);
if (!f.exists() || !f.isFile())
{
return false;
}
RandomAccessFile data = new RandomAccessFile(f, "r");
setDataSource(data.getFD(), offset, size);
releaseBitmapRenderer();
if (android.os.Build.VERSION.SDK_INT >= 16)
{
MediaExtractor extractor = new MediaExtractor();
if (extractor != null)
{
extractor.setDataSource(data.getFD(), offset, size);
updateTrackInfo(extractor);
extractor.release();
extractor = null;
}
}
}
catch(IOException e)
{
GameActivity.Log.debug("setDataSource (file): Exception = " + e);
return false;
}
return true;
}
It seems that only to place to return a False. One is line 205.
if (!f.exists() || !f.isFile())
{
return false;
}
and
catch(IOException e)
{
GameActivity.Log.debug("setDataSource (file): Exception = " + e);
return false;
}
By the Logcat I am sure is some thing wrong with “!f.exists() || !f.isFile()”. But I tried to use LE File Manager plugin to see this folrd. I can see the file right here and it dose exists. I really don’t know where I did wrong. T_T
All I want to do is a media player that can find and play videos in the storage. It seams that my game can only play videos in “Movies” folder.