android - 如何在 Android 中使用 `MediaElement` 播放声音?
问题描述
我MediaElement
用来在 Uno-Platform 项目中播放声音。
它在 UWP 项目中运行良好,但在 Android 项目中不起作用。
音频文件作为Exclude from project位于共享项目中,在 UWP 项目中链接为Content
,在 Droid 项目中链接为AndroidAsset
。
XAML:
<MediaElement Source="/Assets/MySound.wav"/>
我也尝试过以编程Source
方式访问它,但ms-appx:///Assets/MySound.wav
没有成功。
解决方案
As of today, local resources are not supported for iOS in the the Windows.Media.Playback.MediaPlayer
class, but adding support for it should be relatively easy.
On Android, it should work, but there's probably another issue, related to the name of the asset, such as casing (android is lower case) or hyphens (transformed to '_' by android).
推荐阅读
- angular - 当我们输入 [Angular] 时如何检测输入字段的变化
- node.js - 为什么 body 是空对象,Express 服务器,方法帖 (2020)
- spring-boot - 如何在 Kubernetes GKE 上部署 Jaeger
- python - 如何通过matplotlib显示每个条形顶部的Y坐标值
- haskell - 构建 Spock 教程示例失败
- python - 在 Jinja2 和 Flask 之间传递自定义 python 对象
- mysql - pymysql.err.InternalError:(1109,“信息架构中的未知表'ALL_PLUGINS'”)
- java - 将字母添加到具有特定计数的列表
- typo3 - 如何为简单的 GET 参数设置 routeEnhancers?
- wordpress - 在 Woocommerce 管理订单列表中显示带有作者和日期的订单备注