Mpmediapickercontroller selecting local audio error running in simulator

Source: Internet
Author: User

One day a group of friends encountered a problem saying that using Mpmediapickercontroller will crash.

[self presentviewcontroller:self. Mediapicker animated:YEScompletion:nil];


Two I run the next, on the real machine is OK, the simulator should add the following code

1.  mpmediapickercontroller does not run in the emulator. Apple points out that in the "Hello Music player" in the "Ipod Library Access Programming Guide". Note: To follow these steps, you need to screw up the emulator to have access to the music library that has been turned off by the ipod.  

Mpmediapickercontroller *picker = [[Mpmediapickercontroller alloc] initwithmediatypes:mpmediatypeanyaudio]; [Picker setdelegate:self]; [Picker Setallowspickingmultipleitems:yes];  [Picker setprompt:nslocalizedstring (@ "Add songs to Play", "Prompt in Media item Picker")]; @try {[Picker loadview];//would Throw an exception on IOS simulator [self presentviewcontroller:picker animated:yes completion:nil];} @catch (NSException *exception) {[[[Uialertview Alloc] initwithtitle:nslocalizedstring (@ "oops!" @ "Error title")        Message:nslocalizedstring (@ "The music library is not available." @ "Error message when Mpmediapickercontroller fails to Lo Ad ")         delegate:nil       cancelbuttontitle:@" OK "       Otherbuttontitles:nil] show];}

2. storyboard(故事板),你可以尝试一下:
-(Ibaction) Showpicker: (ID) sender{#if target_iphone_simulator Uialertview *alert = [[Uialertview alloc] InitWithTitle: @ "PlayerTest"             message:@ "Media picker didn ' t work in simulator, click Run this app on device"             Delegate:nil           CA ncelbuttontitle:@ "OK"           Otherbuttontitles:nil]; [Alert show]; #else [self performseguewithidentifier:@ "Showpickerviewsegue" sender:self]; #endif}

It's OK.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Mpmediapickercontroller selecting local audio error running in simulator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.