2017-03-06 20 views
0

假設用戶將iphone的響度設置爲5/10的值,我想將應用程序結果的音量從0%增加到100%,其中100%是5/10(設置的值由用戶)。我想讓這個動作緩慢增加,例如20秒。增加應用程序輸出的響度

如果我理解正確,應用程序不能超過用戶設置的最大音量輸出值。

不幸的是我找不到辦法做到這一點。我應該從哪裏開始完成這項任務?

我想發出警報。

現在我使用以下邏輯發送推送通知,即「喚醒」用戶。

- (void)sendLocalPushForAlarm { 
    if (IS_OS_8_OR_LATER) { 
     [self registerForLocalNotification]; 
    } 

    UILocalNotification *notification = [[UILocalNotification alloc] init]; 
    [notification setAlertBody:NSLocalizedString(@"WAKE_UP", nil)]; 
    if (IS_OS_8_OR_LATER) { 
     [notification setCategory:NotificationCategoryIdent]; 
    } 
    [[UIApplication sharedApplication] presentLocalNotificationNow:notification]; 
} 

回答

2

你可以小隊響度的唯一方法是,當你的應用程序在前臺運行(或者說:如果你使用手動如AVPlayer播放正確的聲音,這是通常不可能在BG,所以我將其簡化爲「僅前景」)

除此之外沒有辦法。

(醜)解決方法,以接近可能:有,在不同的響度級記錄


==>我的投票就沒有辦法

+0

我使用多個聲音文件的多個通知:如果([AVAudioSession sharedInstance] .category!= AVAudioSessionCategoryPlayback){[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; [[AVAudioSession sharedInstance] setActive:YES error:nil]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self becomeFirstResponder]; –

+0

啊我覺得我沒有把握好。那麼當您再次進入應用程序後,您是否會在通知後播放聲音? –

+0

是的,但我想從0%增加到100%,現在它從100%開始:) –

相關問題