MPMoviePlayerController undeclared (first use in the function) message - iphone

I dont know why I am getting this message when I click have this code
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] iniWithContentURL: url];
Is there something, I am missing here?
Thanks

You need to import/include the movie player:
#import <MediaPlayer/MediaPlayer.h>
Furthermore, the MediaPlayer.framework must be added to your "Frameworks" folder in the XCode project.
To add the framework, right-click on "Frameworks", then select the path on your system where this framework resides. On my system it is under the following path:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/MediaPlayer.framework

Make sure you are linking to MediaPlayer.framework in your Xcode project. That's where MPMoviePlayerController comes from and if you don't link to it, the linker won't know what it is.

MediaPlayer.framework must be added to your "Frameworks" and #import <MediaPlayer/MediaPlayer.h> in your .h file

Related

AVMediaTypeVideo not working for flashlight app

line in my code
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
for AVMediaTypeVideo xcode tells me ...
Use of undeclared identifier 'AVMediaTypeVideo'; did you mean 'kCMMediaType_Video'?
a side note, I do have #import AVFoundation/AVCaptureDevice.h in my header
I am trying to make a "flashlight" effect in an app, that is the only line of code with a problem, according to Xcode ...
Have you imported the AVFoundation Framework into to your project?
Add #import <AVFoundation/AVFoundation.h> to your .m
Try to add #import <AVFoundation/AVMetadataFormat.h>

Sound issue in Xcode 4.3.2

I updated to OS X Lion 10.7.3 and to Xcode 4.3.2. I am unable to play a sound on the iPhone Simulator or on the iPhone device with the following code. I am able to play a sound using the same code on Snow Leopard and Xcode 4.2. I have no idea why I am not able to hear the sound in 4.3.2. Can any one help?
.h file
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#interface soundViewController : UIViewController {
}
-(IBAction)playSounds:(id)sender;
#end
.m file
-(IBAction)playSounds:(id)sender {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) #"E", CFSTR("caf"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
XCode 4.3 sometimes excludes files from the copy resources list for no reason. Verify that the file is included in your target. Even if you add it, sometimes it does not become a resource for the target. Click on the file and choose the left most tab of the property inspector, and make sure the checkbox next to your target is checked in the "Target Membership" section.

Open file in another app

My app needs to open some file types in other apps, like dropbox app does, it could list the installed apps which could open specific types of file.
How can get the app list?
You'll want to use UIDocumentInteractionController. See also the Document Interaction Programming Guide.
You can use QLPreviewController from the official docs.
Expanding on jtbandes's answer, here's the code that worked for me:
NSURL *url = [NSURL fileURLWithPath:filePath];
UIDocumentInteractionController *popup = [UIDocumentInteractionController interactionControllerWithURL:url];
[popup setDelegate:self];
[popup presentPreviewAnimated:YES];
And don't forget to include this in your H file:
#interface MyViewController : UIViewController <UIDocumentInteractionControllerDelegate>
Also worth noting: this will open a new fullscreen view that has a Document Viewer, as well as the Share button that offers all the various apps that can open this file. If you're just looking for the Share popup, equivalent to the UIActivityViewController, this will do it, but with some extra functionality you may not want.

save videos in iphone simulator & upload it to the web services

I just want to know that how I can save the videos to the iphone simulator & how I can upload it to the web services?
Thanks.
vpc=[[UIImagePickerController alloc] init];
vpc.delegate=self;
vpc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
vpc.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:vpc.sourceType];
vpc.allowsEditing = NO;
vpc.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
[self presentModalViewController:vpc animated:YES];
i am doing this it gives an error, kuTType undeclared before it used, i dont know about the kuTTypeMovies, please reply as soon as possible.
Thanks
I think you are missing one of below framework
libz.1.2.3.dylib
MobileCoreServices.framwork
SystemConfiguration.framwork
You need to import framework #import MobileCoreServices/UTCoreTypes.h
If u got an error when u import framework.try below method I found.
1) open your project profile
2) build phases > link binary with libraries
3) click + , add MobileCoreService framework
4) now see it in left side.In the Headers folder of framework.find file name MobileCoreServices.h
5) Now open .h file, simple drag it below #import UIKit/UIKit.h
Note : make sure you need to drag it into #import<....>
Now what...? Thats it.You can see KuTTYpeMovie in .m file...thanks

UIWebView leak? Can someone confirm?

I was leak-testing my current project and I'm stumped. I've been browsing like crazy and tried everything except chicken sacrifice. I just created a tiny toy project app from scratch and I can duplicate the leak in there. So either UIWebView has a leak or I'm doing something really silly.
Essentially, it boils down to a loadRequest: call to a UIWebView object, given an URLRequest built from an NSURL which references a file URL, for a file in the app bundle, which lives inside a folder that Xcode is including by reference. Phew.
The leak is intermittent but still happens ~75% of the time (in about 20 tests it happened about 15 times). It only happens on the device -- this does not leak in the simulator. I am testing targeting both iPhone OS 3.1.2 and 3.1.3, on an original (1st Gen) iPod Touch that is using iPhone OS 3.1.3.
To reproduce, just create a project from scratch. Add a UIWebView to the RootViewController's .xib, hook it up via IBOutlet. In the Finder, create a folder named "html" inside your project's folder. Inside that folder, create a file named "dummy.html" that has the word "Test" in it. (Does not need to be valid HTML.) Then add the html folder to your project in Xcode by choosing "Create Folder References for any added folders"
Add the following to viewDidLoad
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
NSString* filePath = [[resourcePath stringByAppendingPathComponent:#"html"] stringByAppendingPathComponent:#"dummy.html"];
NSURL* url = [[NSURL alloc] initFileURLWithPath:filePath];
NSURLRequest* request = [NSURLRequest requestWithURL:url]; // <-- this creates the leak!
[browserView loadRequest:request];
[url release];
I've tried everything from setting delegate for the UIWebView and implementing UIWebViewDelegate, to not setting a delegate in IB, to not setting a delegate in IB and explicitly setting the web view's delegate property to nil, to using alloc/init instead of getting autoreleased NSURLRequests (and/or NSURLs)...
I tried the answer to a similar question (setting the shared URL cache to empty) and that did not help.
Can anyone help?
Try:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:#"WebKitCacheModelPreferenceKey"];
}
From http://blog.techno-barje.fr/post/2010/10/04/UIWebView-secrets-part1-memory-leaks-on-xmlhttprequest
Forgot about this question.
The leak is not present in 4.1. I would assume the same for 4.2.