ios - 从 Apple Watch 扬声器播放声音

标签 ios objective-c iphone audio apple-watch

有没有办法从 Apple Watch 的扬声器中播放声音?我无法在网上找到任何文档。

最佳答案

现在可以使用 WKAudioFilePlayerWKInterfaceMovie 从 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 扬声器播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28980152/

相关文章:

iphone - 在 iOS 中使用该应用程序时,有没有办法动态删除标签栏或将标签添加到标签栏?

android - Scala Comet 和移动应用程序

ios - iOS鼓音序器-缓冲区问题(错误访问)

ios - 如何获得具有相同屏幕宽度的 WebView ?

c - 编程简单的音调发生器,在两个立体声中各播放一个音调

ios - 无法在控制台中打印我的json数据?

ios - 如何使用 NSPredicate 过滤这个对象数组?

ios - 设置背景图像后按钮变为蓝色

iphone - 如何将 NSString 对象传递给 stringByAppendingFormat :

iphone - 横向调整带有 UIAppearance 的 UIBarButtonItem (UIEdgeInsets)