Question

Trying to implement AVAudioplayer and get some metering data of the played music, but still getting value -160. It looks easy to use, just enable Meter and then pickup data under a timer, but no results so far.

playerAV = [[AVAudioPlayer alloc] initWithContentsOfURL:outURL error:nil];
        playerAV.delegate = self;


        playerAV.meteringEnabled = YES;

        [playerAV prepareToPlay];
        [playerAV play];

NSLog(@"Peak left: %f Avg right: %f", [playerAV peakPowerForChannel:0],[playerAV averagePowerForChannel:1]);

any thoughts are welcome.

Était-ce utile?

La solution

Are you calling updateMeters? The docs for both peakPowerForChannel: and averagePowerForChannel: say:

To obtain a current [...] value, you must call the updateMeters method before calling this method.

Autres conseils

How do you know the url works, and the data at the end of it is the right format? Can you hear stuff coming from the speakers?

Are you somehow making two playerAV objects, one with the correct URL which plays, the other with a bad url which plays nothing, and is the one that the timer sees when it calls NSLog()?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top