- Home /
iOS: Handheld.PlayFullScreenMovie
I seem to be unable to play movies using this line:
Handheld.PlayFullScreenMovie( fileName, Color.black, FullScreenMovieControlMode.Hidden, FullScreenMovieScalingMode.Fill);
the filename is right (as verified by a call to System.IO.File.Exists( fileName ) - which fails if I give bad filenames) and I've tried movies shot on the iPhone, movies from Apple's owan site, labelled as transcoded for iPod, etc, so I'm sure the format is right.
However, I continually get a crash on:
playmovie(4953,0x1e03000) malloc: error for object 0x1c849b8: pointer being freed was not allocated set a breakpoint in malloc_error_break to debug
If I give it a bad filename, the movieplayer starts then closes again (without crashing). As far as I can tell, I'm giving it a good filename and file.
I'm testing on devices running iOS 5.1
Any suggestions? Does anybody have a working movie file / demo project I could see with this all working? I'm amazed a one-liner that should Just Work is proving so problematic.
Answer by scottyboydee · Apr 13, 2012 at 08:56 AM
I sort of solved this...
In the end, I realised that I was using the developer preview of Unity 3.5, and went back to Unity 3.43 (at the time, the most recent fully-stable build).
This did mean that I had to recreate my scene entirely (lost about half a day to doing that) but the calls worked and I got my product made on time in the end.
Here's my code - the bit that finds the path is very hacky, I suspect you don't need all that (there are other articles on this subject), but all I can say is that it worked, so perhaps it could form part of a solution for you.
I also used iExplorer to go on my device, into the directory of my app and check for absolutely certain that the movie file had been copied into the directory on the device (though while I deploy, you could usually see the status in Xcode change when it was copying the bigger resources, so I was pretty sure).
string getStreamingPath()
{
string path = Application.persistentDataPath;
string docName = "Documents";
string newPath = path.Substring( 0, path.Length - docName.Length );
newPath += "TestMovie.app/Data/Raw/";
return newPath;
}
public void play( string movieName )
{
print ("Starting!");
string path = getStreamingPath();
string fileName = path + movieName;
if( System.IO.File.Exists( fileName ) )
{
print ("File EXISTS");
}
else
{
print ("File NOT FOUND");
}
fileName = "file://"+fileName;
print("Starting fullscreen movie: "+fileName);
iPhoneUtils.PlayMovieURL( fileName, Color.black, iPhoneMovieControlMode.CancelOnTouch);
}
Like I say, this is pretty bad code, but hey, I'm new, I was in a very big rush ;)
Hope some of that might be useful to you, I didn't find anything (on three different forums) that worked for me beside going back a version of Unity :/
$$anonymous$$aybe going forward? I had no such issues before 3.5, in 3.5.0b6 or 3.5.2f2, both for iPhone and Android.
Answer by Haxx0rz · Jul 24, 2012 at 09:41 PM
I had the same problem, where the player in the iPad closes on its own, but I was able to fix it. The reason, I had an incompatible file type (.ogv). Here
- MPEG-4 Part 2 video [Source here][1] I used iPhoneUtils.PlayMovieURL by the way. It still seems to work (using Unity iPhone Pro 3.5.0f5) even though it does not appear in the autocomplete or marked as [Obsolete] when I type it in MonoDevelop. Took me a while to fix this one as well, but I hope it helped out. [1]: http://docs.unity3d.com/Documentation/Manual/VideoFiles.htmlUnity iOS supports any movie file types that play correctly on an iOS device, implying files with the extensions .mov, .mp4, .mpv, and .3gp and using one of the following compression standards:
H.264 Baseline Profile Level 3.0 video