Ipad MPMovieplayerController video loads but automatically pauses when played - xcode

I am trying to get the MPMovieplayerController to work. I load a video everything goes wel i even see the first frame but then it automatically pauses, if i press play it pauses again. In the simulator it works perfectly but on the ipad device it gives the problem. I can even seek through the video and i see the frame i seeked to but nothing plays. This is some output from the console:
2010-06-08 22:16:13.145 app[3089:207] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
[Switching to thread 12803]
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2 (7B367)/Symbols/System/Library/VideoDecoders/VCH263.videodecoder" (file not found).
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2 (7B367)/Symbols/System/Library/VideoDecoders/H264H2.videodecoder" (file not found).
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2 (7B367)/Symbols/System/Library/VideoDecoders/MP4VH2.videodecoder" (file not found).
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2 (7B367)/Symbols/System/Library/VideoDecoders/JPEGH1.videodecoder" (file not found).
2010-06-08 22:16:15.145 app[3089:207] setting file:///private/var/mobile/Applications/46CE5456-6338-4BBF-A560-DCEFF700ACE0/tmp/MediaCache/
I dont get those warning when using the simulator BTW.
Does anyone know how to fix this ?

Set the property "useApplicationAudioSession" of the MPMoviePlayerController to "NO" to resolve the problem.

Found the solution just restart the ipad and it works again weird but thats it :)

Had the same problem. Video was playing ok on simulation but not on device. The problem was either on my HTML5 code embeded in the UIView or on the mp4 video compression, I don't know what fixed it but I suggest you try both. I am still getting the error when I am testing the video on the device, but the video plays just fine!

I had an issue on the device where the video would show up but not play. I could scrub. The fix for me was that I was using the avaudiorecorder, and I was releasing it before playing the video without stopping the audio recorder. My solution was to add the stop call to the recorder before starting the video:
[recorder stop];
[recorder release];

Avaudioplayer was causing my problem. Apperently on the iPad Avaudioplayer and Mpmovieplayercontroller cannot both play at the same time.
If an Avaudioplayer object is open the Mpmovieplayer will only display a frame and immediately stop playing.
As far as I can tell this only happens with iPad device 3.2.1 and SDK 4.0.1; simulators and the iPhone work fine
I switched back to Audioservices since I need Audioplayer and Movieplayer to play at the same time.

Related

iOS video toolbox gives "Ignoring enqueueSampleBuffer: because status is "failed""

I am using video toolbox in iOS8 to play an h264 stream along with a PCM audio stream. Video is displayed fine as long as I dont start the audio stream. As soon as I call AudioQueueStart, all enqueueSampleBuffer calls stop displaying video and prints the error "Ignoring enqueueSampleBuffer: because status is "failed"".
There are no errors returned from CMBlockBuffer calls. enqueueSampleBuffer doesnt return anything and hence I cant write a code to recreate video layer again on this error.
This only happens on iOS device and not on simulator. Audio and video plays perfectly fine on Simulator. I run Audio and Video on separate threads such that one doesnt block the other. Has anyone faced the same issue?
The problem was happening because I had the mute switch on iphone turned ON.
I used AVAudioSessionCategoryPlayback for my audio session to overcome this.
This problem is resolved.

Xcode keeps pausing my music

First of all i know this is a programming forums, but my problem concerns Xcode and the problem happens with me while CODING.
When i use Xcode, when it is stopped in breakpoints while debugging the sound of the music played ( in my Mac music player ) is gone !!! i know this is awkward but it happens. Does any one has a solution or at least a reason for this?
After googling this problem i just found one case talking about the same problem here in this Link
I'm not using Spotify like the case in the link i'm using another music player called Vox
I have changed Vox and changed it with Deezer and it has the same problem
Update 1
As mentioned in the Accepted Answer, This problem only happened while using Cocos2dx in Xcode, When i returned back to the use Xcode with just iOS sdk without the Cocos2dx this problem doesn't exist any more.
This is happening when your capture audio session in your application and debug something.
The case to reproduce this using Xcode + simulator (on device you will have phone's audio session, so it can not be reproduced with the following snippet). Sometimes it stops just after breakpoint occurs, sometimes - after about a minute (i think, session expires after that time, or something like that)
Create empty project and override didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
if (setCategoryError) // set breakpoint here
NSLog(#"Error setting category! %#", setCategoryError);
return YES;
}
I think, on breakpoint session somehow stops music playing. so - check your project for the code, which manipulates with audio session (AVAudioSession).
Hope, this helps.
I had the same issue and I figured it had something to do with CocosDenshion. Do you use it? If so, try to not create a CDSoundEngine. Does it fix the issue? You could create it only in your release build.
Had the same problem, super annoying.
Fixed it by routing sound through soundflower.
https://github.com/mLupine/SoundflowerBed/releases
Then install soundflower bed:
https://github.com/mattingalls/Soundflower/releases/tag/2.0b2
Look for the soundflower icon in your menu bar on the right, select your output device of choice, then go to your sound options and select soundflower as the output.
Hope that helps!
The Simulator is the iOS/watchOS/tvOS user space running on the host mac kernel, so it shares its audio subsystem with the mac. When stopped in the debugger none of the audio callbacks can be serviced. I suspect this happens when you have an active audio session with active callbacks.
Please file a bug at https://bugreport.apple.com and provide a sample project if you can.

iOS 7 Background Audio

I'm trying to play audio in background on iOS 7. While everything worked nicely in iOS 6 it stopped to work now. If I put my app into background my audio keeps playing but as soon as I start another Audio-app like a synth app, my app can't do anything any longer (no audio / timers stopped etc.)
I'm using this code to set the audio session:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
What can I do to be still able to play audio / send midi events even if another music/audio app is in the foreground?
For playing audio effects I use FMOD.
I think you want
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error: nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
:AVAudioSessionCategoryOptionMixWithOthers I think does what you want, although it's not entirely clear. Let me know if that works!

Why does audio work in the simulator but not on my iPad?

I am working on creating a very simple app. 2 buttons, both play sound. Each clip lasts 1 second and responds to "TouchUpInside". They are .caf files that I converted in iTunes.
Here is my code, once again, it works in the simulator but not on the device:
enter code here- (void)viewDidLoad {
NSLog(#"InView did load");
AudioServicesCreateSystemSoundID ((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:#"bigaif" ofType:#"caf"]], &systemSoundID);
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource: #"smallwav" ofType:#"wav"]],
&systemSoundIDTwo);
}
-(IBAction) playSound:(id) sender {
AudioServicesPlaySystemSound(systemSoundID);
}
-(IBAction) playSoundTwo:(id) sender {
AudioServicesPlaySystemSound(systemSoundIDTwo);
}
After looking for errors in my code for the past 30 min I found that the mute button on the side of iPad was on. Check that before trying some fancy solution.
30 min well spent...
I found my answer. I was using SystemSound and what do you know, I had my system sounds muted in my device settings.
I had same issue. I didn't add a link reference to the AudioToolbox.framework but it still worked on simulator.
I added it and it played in the foreground of my app on the device.
Then I wanted it to play the sound in the background. In info.plist "Required background modes" add the key "plays audio". That got it working the background.
This happened to me as well. Sounds were playing just fine in the simulator, but not on the device. I tried to play the sounds multiple different ways. I used both SystemSound and AVAudioPlayer with the same results. I even downloaded the code from a Mobile Orchard tutorial, and had the same result. Code example worked fine in simulator, but wouldn't play on the device.
After 2 hours of this, I double-tapped the home button on the iPad, scrolled to the left to the sound controls, and then tapped the speaker icon on the left. That placed a slash through the speaker icon to indicate that system volume was muted. I then tapped again, the slash went away, and I was then able to play sounds through the device.
So basically, I had to toggle through the muted state of the device using this method and that reset something on the iPad to where I could hear the sounds.
Note that this was on iOS6.

Quicktime Framework and opening Transport Streams

I have noticed that Quicktime 10 is now able to open Transport Stream Video files and also search reliably within that video file(Which is something that VLC can not seem to handle). Quicktime 7, on the other hand, is not able to open the same Video File.
When I try to open that same Video File within my Cocoa Application, which is using the QTKit framework, I get the error that the selected file is not a movie file.
Are there anyways to work around this?
Also, does anyone know the difference between the Quicktime Player and the QTKit that is supplied to developers? I made the assumption that the QTKit framework would backing the player but this does not seem to be the case.
QuickTime Player should use an almost identical backing as any other app on the system: QTKit. What might be happening is that QuickTime Player in Snow Leopard is using the newly introduced QuickTime X system, rather than the more venerable QuickTime 7. Read up on QuickTime X and see if that helps. (It should boil down to specifying that you want playback only when opening the URL).
It seems that QTKit by default uses QuickTime 7 but can be made to use QuickTime X by setting the QTMovieOpenForPlaybackAttribute attribute. This will disable some quick time features like setting the selection and playing the selection but QTKit will now be able to play Transport Streams.
You can read more about it with in the following pdf.
http://macguild.org/wwdc/wwdc-2009.pdf
I understand this is quite irrelevant to the question asked. However, I hope it will help someone wandering around to know how to open a URL from a Cocoa app with the default QuickTime Player application and not the ugly QTMovieView etc. I'd to spend a good deal of time and labour googling about it but all in vain.. I hope it will save someone's day.
NSString *url = [NSString string];
url = #"http://someurl";
[[NSTask launchedTaskWithLaunchPath:#"/usr/bin/open" arguments:[NSArray arrayWithObjects:url , #"-a", #"QuickTime Player", nil]]
waitUntilExit];

Resources