10

2 つのエラーに直面しました。

このコードは iOS 4 および 5 で動作しましたが、6 にアップデートした後は動作しません (

以下を見つけましたが、コードで修正する方法がわかりません。

iOS 6 以降、CoreMIDI の MIDISourceCreate および MIDIDestinationCreate 関数を使用するには、アプリの UIBackgroundModes にオーディオ キーが必要です。キーが設定されていない場合、これらの関数は kMIDINotPermitted (-10844) を返します。

2012-09-23 03:40:04.773 MidiStudio[1017:907] エラー (MIDI 仮想ソースの作成): -10844:Error Domain=NSMachErrorDomain Code=-10844 "操作を完了できませんでした。(Mach エラー -10844. )"

2012-09-23 03:40:04.777 MidiStudio[1017:907] エラー (MIDI 仮想宛先の作成): -10844:エラー Domain=NSMachErrorDomain Code=-10844 「操作を完了できませんでした。(Mach エラー -10844. )"

「ソース」のコードは次のとおりです。

-(void)setVirtualSourceEnabled:(BOOL)virtualSourceEnabled {
    if ( virtualSourceEnabled == self.virtualSourceEnabled ) return;

    if ( virtualSourceEnabled ) {
        NSString *name = virtualEndpointName ? virtualEndpointName : [[[NSBundle mainBundle] infoDictionary] valueForKey:(NSString*)kCFBundleNameKey];

        OSStatus s = MIDISourceCreate(client, (CFStringRef)name, &virtualSourceEndpoint);
        NSLogError(s, @"Create MIDI virtual source");
        if ( s != noErr ) return;

        virtualSourceDestination = [[PGMidiVirtualSourceDestination alloc] initWithMidi:self endpoint:virtualSourceEndpoint];

        [delegate midi:self destinationAdded:virtualSourceDestination];
        [[NSNotificationCenter defaultCenter] postNotificationName:PGMidiDestinationAddedNotification
                                                            object:self 
                                                          userInfo:[NSDictionary dictionaryWithObject:virtualSourceDestination
                                                                                               forKey:PGMidiEndpointKey]];

    } else {
        [delegate midi:self destinationRemoved:virtualSourceDestination];

        [[NSNotificationCenter defaultCenter] postNotificationName:PGMidiDestinationRemovedNotification
                                                            object:self 
                                                          userInfo:[NSDictionary dictionaryWithObject:virtualSourceDestination
                                                                                               forKey:PGMidiEndpointKey]];

        [virtualSourceDestination release]; virtualSourceDestination = nil;
        OSStatus s = MIDIEndpointDispose(virtualSourceEndpoint);
        NSLogError(s, @"Dispose MIDI virtual source");
        virtualSourceEndpoint = NULL;
    }
}
4

3 に答える 3

14

[Just putting my notes here on Kurt's excellent answer.]

First off, this is all mentioned in the document called "iOS 6.0 Release Notes." The line there says:

Beginning in iOS 6, apps need to have the audio key in their UIBackgroundModes in order to use CoreMIDI’s MIDISourceCreate and MIDIDestinationCreate functions. Without the key set, these functions will return kMIDINotPermitted (-10844).

So the only thing you need to do (again, just specifying what Kurt answered) is something like this in each target's plist:

<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
</array>
于 2012-09-25T15:17:42.920 に答える
7

コードを変更する必要はありません。そのメッセージをもう一度読んでください。

iOS 6 以降では、アプリの UIBackgroundModes にオーディオ キーが必要です。

UIBackgroundModesアプリケーションの Info.plist のキーです。Xcodeを使用してアプリの Info.plist を編集し、そのキーの値を string を含む配列にしますaudio

于 2012-09-23T03:24:02.453 に答える
1

私のアプリは MIDIDestinationCreate を使用して midi ファイルを再生しますが、アプリ レビュー チームは確かに悪臭を放っています。彼らは、アプリがバックグラウンドでオーディオを再生する必要があると主張しています. 彼らは、「2.16: マルチタスク アプリは、意図された目的のためにのみバックグラウンド サービスを使用することができます: VoIP、オーディオ再生、場所、タスク完了、ローカル通知など」を引用しています。

ここに記載されている iOS6 のリリース ノートを参照してもらいましたが、バックグラウンドでオーディオを再生する必要があると何度も言われました。

Apple Developer Technical Support にリクエストを送信しました。彼らのチームが従うアプリレビューのガイドラインを変更してくれることを願っています。

于 2014-07-18T16:57:47.753 に答える