在iOS上向地图添加音频 [英] Add audio to Map on iOS
问题描述
我现在有一张地图,上面有几个非常接近的点.现在,当用户点击注释时,会弹出一个带有位置名称的弹出窗口.我如何才能播放有关该位置的音频?
I have a map right now with several points on it that are quite close to each other. Right now when a user taps the annotation a little pop up occurs with the location name on it. How could I have it so that a piece of audio about that location plays?
我对暂停按钮等还不是很着迷,现在我想知道如何在其中实现音频!
I'm not too fussed about pause buttons etc yet, right now I want to know how I'd implement audio into this!
推荐答案
使用
http://jonathanfield.me/avspeechsynthesizer-ios-text- speech-ios-7/ 更新: 将委托添加到您的MKMapView.例如,它可能是 Add delegate to your MKMapView. For example it could be (自身应向MKMapViewDelegate确认).并实现委托的方法 (self should confirm to MKMapViewDelegate). And implement delegate's method 这篇关于在iOS上向地图添加音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!self
self
self.mapView.delegate = self;
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)anView
{
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:anView.annotation.title];
[utterance setRate:0.7];
[synthesizer speakUtterance:utterance];
}