iOS完成录制后,关闭AV Audio Recorder的红色状态栏

时间:2017-07-13 18:36:45

标签: ios objective-c audio-recording avaudiorecorder

我的应用记录请求使用权限,后台录制。尽管没有其他人似乎在录制,我喜欢录制红色状态栏。我的问题是关闭它......

这是我完成录制过程时使用的代码:

val dailyshow = Seq(
  ("1999", "actor", "1/11/1999", "Acting", "Michael J. Fox"),
  ("1999", "Comedian", "1/12/1999", "Comedy", "Sandra Bernhard"),
  ("1999", "television actress", "1/13/1999", "Acting", "Tracey Ullman"),
  ("1999", "film actress", "1/14/1999", "Acting", "Gillian Anderson"),
  ("1999", "actor", "1/18/1999", "Acting", "David Alan Grier")
).toDF(
  "year", "occupation", "showdate", "group", "guest"
)

dailyshow.createOrReplaceTempView("dailyshowView")

val dailyshow2 = spark.sqlContext.sql("""
  SELECT occupation, count(*) as count FROM dailyshowView
  WHERE to_date(cast(unix_timestamp(showdate, 'MM/dd/yyyy') as timestamp)) >= '1999-01-11'
    AND to_date(cast(unix_timestamp(showdate, 'MM/dd/yyyy') as timestamp)) <= '1999-06-11'
  GROUP BY occupation
  LIMIT 5
""")

dailyshow2.show
+------------------+-----+
|        occupation|count|
+------------------+-----+
|      film actress|    1|
|             actor|    2|
|          Comedian|    1|
|television actress|    1|
+------------------+-----+

我希望一旦完成录制(或至少在此后不久),这个红色条就会消失,让用户知道它已经完成。显然它拒绝了,快速谷歌搜索将显示其他一些人也有类似的问题。任何人都可以告诉我解决方案是什么,因为我发现至少有2个应用程序可以正确响应停止录制并在适当的时候关闭它。

1 个答案:

答案 0 :(得分:0)

原来我只缺少几行代码......这里是:

- (void)stopRecording {
    [self.recorder pause];
    [self.recorder stop];
    self.recorder = nil;

    [self.audioSession setActive:NO error:nil];
    [self.audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
    self.audioSession = nil;
}