I'm trying to write a media player in.Net MAUI with the new MediaElement, and so far everything seems okay. The only issues that I'm facing is that there seems to be no support for accessing the Media Controls in the System UI, that the android API supports (see here for an example of what I'm after: https://developer.android.com/media/implement/surfaces/mobile).
我正在尝试用新的MediaElement在.Net MAUI中编写一个媒体播放器,到目前为止一切都还可以。我面临的唯一问题是,似乎不支持访问android API支持的系统UI中的媒体控件(请参阅此处获取我所追求的示例:https://developer.android.com/media/implement/surfaces/mobile)。
All I'm trying to achieve is to display that notification with the information of what's currently being played, and to be able to call methods in my application with the controls on that UI (play, pause, seek, etc.) If anyone could point me in the right direction, it would be greatly appreciated.
我所要实现的就是显示带有当前播放内容信息的通知,并能够使用UI上的控件(播放、暂停、查找等)调用应用程序中的方法。如果有人能为我指明正确的方向,我将不胜感激。
I've tried googling, binging and duck-duck go-ing, all to no avail. I haven't been able to find a lead for this issue at all so far, but perhaps I just haven't searched far enough.
我试过在谷歌上搜索、binging和duck duck go,但都没有用。到目前为止,我还没有找到这个问题的线索,但也许我只是搜索得不够远。
Thanks,
Oli
谢谢,奥利
更多回答
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
请澄清您的具体问题或提供更多详细信息,以突出您的需求。正如目前所写的,很难准确说出你在问什么。
优秀答案推荐
Oli,
奥利,
I am on a similar journey but you seem to be somewhat ahead of me. I am coming from a Xamarin background and just starting Maui work. This is probably less of an answer and more some direction on your journey.
我正在经历一段类似的旅程,但你似乎在我前面。我来自沙马林,刚刚开始毛伊岛的工作。这可能不是一个答案,而是你旅程中的一些方向。
MediaElement is implemented via ExoPlayer on Android (unclear if Exoplayer2 or 3 yet to me). You might look at the exoplayer documentation. You might need need to customize the Maui handler for Android.
MediaElement是通过Android上的ExoPlayer实现的(我还不清楚Exoplayer2还是3)。你可以看看系外层的文献。您可能需要为Android自定义Maui处理程序。
Looking at your linked docs, it looks like you may be responsible to set up an MediaSessionService derived class to link common media controls (play/pause/next track, etc) to commands in your app. I have never tried this in Maui, but doing similar stuff in Xamarin was usually possible, if not always well documented. A quick search doesn't show any Maui examples. If I get to that point in my app before you find an example, I will post what I come up with.
查看链接的文档,您可能有责任设置一个MediaSessionService派生类,将常见的媒体控件(播放/暂停/下一个曲目等)链接到应用程序中的命令。我从未在毛伊岛尝试过,但在Xamarin做类似的事情通常是可能的,如果不是总是有很好的记录的话。快速搜索没有显示任何毛伊岛的例子。如果在你找到例子之前,我在我的应用程序中达到了这一点,我会发布我的想法。
更多回答
Hey Jeremy, thanks for the comment. I definitely do think what I'm trying to implement is possible. I saw that the MediaElement had it's roots in ExoPlayer, so perhaps you're right. I'm largely coming from a .net desktop application background, never really having touched Xamarin or Maui, but it seems like there's a way, I just need to keep banging rocks together to get there.
嘿,Jeremy,谢谢你的评论。我确实认为我试图实现的是可能的。我看到MediaElement源于ExoPlayer,所以也许你是对的。我主要来自.net桌面应用程序背景,从未真正接触过Xamarin或Maui,但似乎有一种方法,我只需要不断地敲击石头就能达到目的。
我是一名优秀的程序员,十分优秀!