сделать звуковые петли оповещения каждые пять секунд - PullRequest
0 голосов
/ 01 июня 2019

Я пытаюсь написать простой цикл звуковых оповещений каждые пять секунд

Как я могу добавить его, пожалуйста

твик для cydia

Шаблон Tweak.xm

     if (lowenabled) {
      if ([batString isEqualToString:lowbatPercent_String]) {
        if (lowplayer) {
          return;
        }

        if (lowsound == 0)
          soundFilePath = [NSString stringWithFormat:@"%@/Super Mario.mp3", bundlePrefix];
        else if (lowsound == 1)
          soundFilePath = [NSString stringWithFormat:@"%@/Super Mario 1.mp3", bundlePrefix];

        soundFileURL = [NSURL fileURLWithPath:soundFilePath];

        lowplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
        lowplayer.numberOfLoops = 3;
        [lowplayer play];
      } else {
        if (lowplayer) {
          lowplayer = nil;
        }
      }
    }
}
%end

1 Ответ

0 голосов
/ 01 июня 2019

Включить в таймер огня:

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(playSound:) userInfo:nil repeats:YES];
[timer fire];

Поместить метод в тот же класс:

- (void)playSound {
 // the code you included here that plays the sound
}

Документы для метода огня NSTimer

...