从Apple关注扬声器播放声音 [英] Play sound from Apple Watch speaker

查看:320
本文介绍了从Apple关注扬声器播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有播放声音了Apple关注的扬声器的一种方式?我一直无法在网上找到的任何文件。

Is there a way to play sound out of the Apple Watch's speaker? I have been unable to find any documentation online.

推荐答案

这是现在可以作为watchOS 2使用 WKAudioFilePlayer WKInterfaceMovie

This is now possible as of watchOS 2 using WKAudioFilePlayer or WKInterfaceMovie.

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];

这篇关于从Apple关注扬声器播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆