如何使用`MediaElement`在Android中播放声音? [英] How to use `MediaElement` to play sound in Android?

查看:28
本文介绍了如何使用`MediaElement`在Android中播放声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 MediaElement 在 Uno-Platform 项目中播放声音.

I'm using MediaElement to play sound in an Uno-Platform project.

它在 UWP 项目中运行良好,但在 Android 项目中不起作用.

It plays well in the UWP project but doesn't work in the Android project.

音频文件位于共享项目中作为从项目中排除,在 UWP 项目中作为 Content 链接,在 Droid 项目中作为 AndroidAsset 链接.

The audio file is located in the shared project as Exclude from project, and is linked in the UWP project as Content and in the Droid project as AndroidAsset.

XAML:

<MediaElement Source="/Assets/MySound.wav"/> 

我还尝试以编程方式访问它,将 Source 设置为 ms-appx:///Assets/MySound.wav,但没有成功.

I've also tried accessing it programmatically set the Source to ms-appx:///Assets/MySound.wav with no success.

推荐答案

MediaPlayerElement 现在在 Uno 中可用(请参阅 MediaPlayerElement 文档)

MediaPlayerElement is now available in Uno (See MediaPlayerElement documentation)

这篇关于如何使用`MediaElement`在Android中播放声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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