ios - 核心 Spotlight API - 搜索结果中的 kUTTypeAudio 播放按钮

标签 ios swift ios9 corespotlight

新的搜索 API 是否可以在搜索结果单元格中添加播放按钮?

我尝试过这样的事情:

let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeAudio as String)
...
attributeSet.contentType = kUTTypeAudio as String
attributeSet.contentURL = NSURL(fileURLWithPath: dataPath)

在主题演讲中,他们搜索了一部电影并得到了带有播放按钮的结果。 也许这在以后的测试版中是可能的?

最佳答案

是和否。查看文档,这始终是我最喜欢提出问题的地方:)。就 Core Spotlight 而言,如果它是一个可行的功能,到目前为止,苹果公司向我们提供的文档中还没有公开注释它。正如您在主题演讲中看到的,他们在您发现包含丰富结果的索引期间讨论了丰富的结果(调用电话号码、播放电影等),更具体地说是在 Web Markup API 期间。讨论,这就是您在主题演讲中看到的内容的原因。他们指出有两种方法可以实现播放电影或音频:

You can also use schema markup to enable actions within rich results. For example, you might let users dial a phone number, get directions to an address, or play audio or video by integrating markup similar to the code shown here:

<!-- Two ways to enable playing audio or video. ->

<!-- Using Open Graph markup: ->
<meta property="og:video:url" content="https://example.com/videofile">

<!-- Using Schema.org markup: ->
<div itemscope itemtype=
   "http://schema.org/AudioObject">
   <meta itemprop="contentUrl"
content="http://example.com/x.m4a" />
</div>

来源

关于ios - 核心 Spotlight API - 搜索结果中的 kUTTypeAudio 播放按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31360530/

相关文章:

ios - NSURLConnection 内存泄漏

ios - 将自定义图像设置为 UIBarButtonItem 但它不显示任何图像

ios - Swift - 从 UICollectionViewCell 获取 UIImage

ios - Swift:使图像在 UIBezierPath(overInRect) 中连续循环

ios - 在 UITableView 的部分中填充行的最佳方法?

mobile-safari - 虚拟点击 iOS9 Safari 中的 "Back to [app]"按钮

swift - 动态更改键盘扩展的高度

ios - NSURLSessionTaskDelegate 是什么时候设置的?

ios - 将 url 存储在 userdefaults 中

ios - 将褪色的深色背景设置为 UINavigationBar