ios – 从Apple Watch扬声器播放声音
2019年10月28日
作者:佚名
有没有办法从苹果手表的扬声器播放声音?我一直无法在线找到任何文件.
解决方法
现在可以通过使用WKAudioFilePlayer或WKInterfaceMovie的watchOS 2来实现.
NSURL *assetURL = [[NSBundle mainBundle] URLForResource:@"file" withExtension:@"wav"];
WKAudioFilePlayer示例:
WKAudioFileAsset *asset = [WKAudioFileAsset assetWithURL:assetURL]; WKAudioFilePlayerItem *playerItem = [WKAudioFilePlayerItem playerItemWithAsset:asset]; WKAudioFilePlayer *audioFilePlayer = [WKAudioFilePlayer playerWithPlayerItem:playerItem]; [audioFilePlayer play];
WKInterfaceMovie示例:
[self presentMediaPlayerControllerWithURL:assetURL options:nil completion:nil];
以上是来客网为你收集整理的ios – 从Apple Watch扬声器播放声音全部内容,希望文章能够帮你解决ios – 从Apple Watch扬声器播放声音所遇到的程序开发问题。
如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。