iOS media picker does not show up

I am currently working on an audio application on iPhone. It is based on apple's SpeakHere sample code with a user-defined input file from iPod library.

Here is the event raised by the button:

- (IBAction) btn_PickSong_Clicked:(id)sender{ [self showMediaPicker]; //code importing tracks from library }

And in showMediaPicker method:

//Yup the program does reach this method but the picker does not show up - (void)showMediaPicker { MPMediaPickerController* mediaPicker = [[[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic] autorelease]; mediaPicker.delegate = self; [self presentModalViewController:mediaPicker animated:YES]; }

The problems are:

  1. The library import feature works fine in a separate program, but the media picker does not show up anymore when I put the code into SpeakHereController.mm.
  2. Also if I place the showMediaPicker method in another class and call it, it does not work either.

Something I find it might be relevant:

  1. The original code is in an obj-C file (xxx.m), and now it's transferred into an obj-C++ file (xxx.mm).
  2. I have also modified the base class of SpeakHereController.h from NSObject to UIViewController<MPMediaPickerControllerDelegate> otherwise it will throw a warning that the base class does not contain the required delegate. But in the interface builder it is still displayed as an object (Please refer to SpeakHere sample code).
  3. It seems that it's illegal to convert the built-in xxxViewController.m file to obj-C++ file (.mm extension). In this case a lot of errors will show up if I attempt to do so. Is it true? If so, how to include C++ code in a pure obj-C file?

=============

So how can I make the media picker show up in this case? Any insight will be appreciated.

Thank you very much!

Cheers,

Manca

-------------Problems Reply------------

In order for

[self presentModalViewController:mediaPicker animated:YES];

to work, self needs to be a viewcontroller. I'm worried that you have just changed the base class to avoid compiler errors as this suggests you are not actually instantiating 'self' correctly.

So how are you initialising the SpeakHereController? As a view controller, this would normally be via the designated initialiser, which for a UIViewController is of course initWithNibName:bundle:

You may find the documentation for UIViewController helpful.

With regards to the C++ issue. Although you can mix objective-c and c++ in the way you suggest, I would recommend that you encapsulate your c++ code in it's own class rather than sprinkling it around your viewcontroller code. That will make it more maintainable for the future.

Category:iphone Views:0 Time:2011-03-07

Related post

  • In iPhone, how to store audio file picked from media picker to some directory? 2011-01-28

    How can I write an audio file picked from mediaPicker into some particular folder? We are currently writing image to file path with this method: [UIImagePNGRepresentation(image) writeToFile:pngPath atomically:YES]; Is it possible for to do the same k

  • Android picker/list similar to iOS date picker 2011-09-13

    I'd like to implement an ios style picker on Android with multiple columns, such as this one: Yes, I know that Android has a slightly different platform default for this kind of UI, but I really like the IOS style that shows the different options abo

  • Is it possible to 're-skin' the IOS Date Picker? 2011-02-04

    I require a custom date picker, essentially just want to remove the graphics in the IOS version but retain the 3 column date scroll. Does it need to be re-built from scratch (all research points to yes) , or is it possible to just disable or swap the

  • Setting the Datepicker in IOS to pick only the Month and Year 2011-06-13

    Good day to you my fellow IOS Programmers... It's fairly a month now since i've started programming in IOS, all fairly are basics.. So I'm wondering, is there any way possible to set the datepicker in XCode-Interface Builder to just use the rollers o

  • Dismissing the iOS safari picker with javascript 2012-01-06

    I am looking for a way to dismiss the select picker found in the iOS Safari once a option element is being selected. We can trigger the whole thing with OnChange, but the picker is still open. I tried .blur() and .blur(function() { window.clearInterv

  • PhoneGap iOS - media.startRecord file URI not working 2012-02-12

    I am trying to use the audio recording as described in the PhoneGap API documentation. But on IOS there seems to be a problem with the file URI for myrecording.wav. I am using the following code to write to a file named myrecodring.wav function recor

  • Apple iOS media dev tools download 2012-02-16

    On Apple's site there is a place where I should be able to download the tools needed to segment media files for http streaming. The page is here: https://developer.apple.com/resources/http-streaming/ The link is on the right side and says "Download t

  • How to play songs from list (array) and not from Media picker 2012-03-16

    I have an app where I have the user pick songs, and then those songs get stored into a Core Data table. I store the Song Name, Artist, Album, and song duration. I need to replay this back. I thought I could load the song names into an array of some s

  • Iphone dev ios not picking up 2x images in ray's application 2012-03-16

    I have downloaded ray wenderlich's code for apns application from this link http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2 now i converted that project of ray's to tab bar application project, now i am having a pro

  • Best way to remove default IOS date picker 2014-05-26

    I currently have the jQuery datepicker implemented which is working great on all browsers but when I view in mobile (iPad) the IOS default date picker comes up too. What is the best way to remove it? CSS? change input type? This is what my input elem

  • Ios Media Server for streaming hosting? 2015-03-17

    I'm building an iOS app which will have audio and video files, can someone recommend me a good media server hosting server where I could put my files and then stream them through the app?

  • Media picker item selection 2011-10-06

    i want my code to allow me to pick multiple items via my ipod library. Currently I am able to select one song. i want to modify my code to allow for a series of songs to be added to the que. Currently selecting YES for "pick multiple items" allows fo

  • iOS 5 Picker View update based on selection? 2012-03-21

    I am working on a project where I want to have a picker view with 3 columns. In the first column I want the user to select a letter. Once the letter is selected I want the second column to update with a list of last names that start with that letter.

  • Phonegap 3.0 Barcode Scanner in iOS only picking up QR codes? 2013-08-14

    This new phonegap overhaul has been a headache, but I've finally managed to get this particular plugin working on my device (sort of). However it seems that only QR codes are working; any other barcodes it just does not detect them. It does not fail

  • Remove Year from date picker in iPhone/iOS app 2011-04-20

    I want to remove year from iOS date picker. Need to use in iPhone app. --------------Solutions------------- You can't use the UIDatePicker because The UIDatePicker only supports the following modes typedef enum { UIDatePickerModeTime, UIDatePickerMod

  • How can I keep track of media created/chosen by UIImagePickerController? 2011-12-12

    I'm building an iOS app that allows the user to upload videos from UIImagePickerController, either by recording or choosing them from the Camera Roll, as well as also play the chosen video. My question is, how would I go about keeping a reference to

  • Retrieving a list of media in umbraco 2009-09-18

    I'm just starting to play with the XSLT system in umbraco where I was hoping to produce a macro which listed all the media under a specific media directory. I have come across umbraco.library:GetMedia but, frankly, I have no idea what to pass to it i

  • Problems with using two Umbraco Media pickers 2009-10-25

    When I added a Media Picker on a Document Type in Umbraco I was able to select an item from the media library but when I added another Media Picker to the same Document Type none of them worked? I am using Umbraco 4.0.2.1 BR, Larre --------------Solu

  • Issue exiting video after playing(ios phonegap app) 2011-05-30

    I am currently using iwebkit and phonegap together. Once everything is compiled and tested on an idevice, I can click a video link and get it to play. It play full screen but it uses the ios web video player (the one that doesn't have the "done" butt

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.090 (s). 11 q(s)