如何创建自定义媒体播放器以在Android中播放自定义编解码器? [英] How do I create a custom media player to play a custom codec in Android?

查看:77
本文介绍了如何创建自定义媒体播放器以在Android中播放自定义编解码器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

n00b在这里(第一个Android项目).我获得了自定义视频编解码器,该编解码器已与Android固件版本集成在一起.这是一个.so文件,其中包含一个继承自MediaPlayerInterface的类以及一个自定义MediaPlayerService实现,以从create()工厂函数返回自定义编解码器类的实例,以获取适当的文件类型.

我想将此编解码器用作视频播放器应用程序的一部分,该视频播放器应用程序可以将.so文件放入我的libs/armeabi文件夹中,并通过JNI进行调用,从而可以将其安装在固件中不包含编解码器的电话中./p>

从答案到这个问题,我认为这是不可能的在MediaPlayer框架中,我必须重新创建一个新的媒体播放器.首先,我用Java实现了一个UI,并将其设置为使用自定义视图(而不是VideoView),该视图扩展了SurfaceView并使用MediaPlayer类的实例播放视频.然后,我用自定义媒体播放器Java类替换了MediaPlayer的此实例.我已经设置了JNI接口,模仿了android_media_MediaPlayer.cpp的实现方式,并在JNI代码中调用了MediaPlayer C ++类.现在,我需要用自定义C ++媒体播放器类替换那个.

这是我开始遇到问题的地方.实施自定义播放器的推荐方法是什么?有一个吗?除了在源代码中进行拖网访问之外,是否还有一些在线文档可用于这些内容?我可以使用多少框架?我必须重新实现多少框架?我是否必须实现自己的等效于MediaPlayerService的内容?

任何提示都将不胜感激.

解决方案

您可以查看Android的源代码,以了解如何Android已用Java实现MediaPlayer接口.你可以遵循类似的路线.

MediaPlayer类参考

n00b here (first Android project). I have been given a custom video codec that has been integrated with an Android firmware build. It's an .so file containing a class that inherits from MediaPlayerInterface, as well as a custom MediaPlayerService implementation to return instances of the custom codec class from the create() factory function for the appropriate file types.

I want to use this codec as part of a video player application that can be installed on phones that do not contain the codec in firmware, by putting the .so file in my libs/armeabi folder and calling it via JNI.

From the answer to this question I gather that it is not possible to do this within the MediaPlayer framework, and I have to create a new media player from the ground up. To start with, I implemented a UI in Java, and set it up to use a custom view (instead of VideoView), which extends SurfaceView and used an instance of the MediaPlayer class to play videos. Then I replaced this instance of MediaPlayer with a custom media player Java class. I've set up the JNI interface, mimicking the way android_media_MediaPlayer.cpp does it, and calling the MediaPlayer C++ class in the JNI code. Now I need to replace that with a custom C++ media player class.

This is where I'm starting to run into problems. What is the recommended approach for implementing a custom player? Is there one? Is there some online documentation for any of this stuff besides trawling through the source? How much of the framework can I use and how much do I have to reimplement myself? Will I have to implement my own equivalent to MediaPlayerService?

Any tips greatly appreciated.

解决方案

You can look up the source code of Android to get an idea about how Android have implemented the MediaPlayer interface in Java. You can follow on similar lines.

MediaPlayer Class Reference

这篇关于如何创建自定义媒体播放器以在Android中播放自定义编解码器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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