Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-07-2011, 08:31 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 6
gc2010 is on a distinguished road
Default Video / audio out of sync on static movies played by MPMoviePlayerController

I have an iPad 1 with iOS 4.2, running an app compiled using Xcode 3.2.5.
The app is implemented using cocos2D framework 1.0.

At a point somewhere in the middle of the app, I would like to introduce a video cut sequence to my game. I instantiate MPMoviePlayerController and use it to play an embedded mp4 file. Once the video starts playing, however, the audio and video are out of sync by as much as 1 second (which, in this case is a lot).

The video file is encoded using H.264 encoding following the iPad guidelines specified by Apple here. However, I've experimented with a variety of other video and audio formats, but to no avail.

I even tried listening to the MPMoviePlayerLoadStateDidChangeNotification message where the player loadState changes to MPMovieLoadStatePlaythroughOK and waiting for 5 seconds after receiving that message to initiate playback, but that didn't help. Using the autoplay feature of MPMoviePlayerController had no effect either.

Does anyone have any suggestions of what else I could try? I couldn't find the mention of this issue anywhere on the web, except for here, but that "fix" doesn't quite apply to me since I'm embedding a video mid-game.
gc2010 is offline   Reply With Quote
Old 07-08-2011, 01:46 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 6
gc2010 is on a distinguished road
Default

It turns out that MPMoviePlayerController has this enigmatic property called useApplicationAudioSession which is set to YES by default. Setting this property to NO "causes the movie player to use a system-supplied audio session with a nonmixable playback category." (wisdom courtesy Apple docs) and, incidentally, fixes the lag problem.

I rely on CocosDenshion (part of Cocos2D) for audio and perhaps the application audio session, as defined and utilized by CocosDenshion is incompatible with the audio session required by the movie player. This is a total speculation though, as I don't fully understand what's going on underneath the hood.

Either way, if you use the system supplied audio session, the video playback is suddenly in sync.
gc2010 is offline   Reply With Quote
Reply

Bookmarks

Tags
mpmovieplayercontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 356
9 members and 347 guests
apatsufas, chemistry, lendo, leostc, Leslie80, lzwasyc, MarkC, SamorodovAlex, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:34 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0