在安卓定制的MediaPlayer类 [英] Custom MediaPlayer class in android
问题描述
我刚刚完成我的使用webwiew视频播放的项目。现在我要求更换的WebView部分与自定义播放器。玩家应该能够处理HLS。
I have just finished a project where I use a webwiew for video playback. Now I am asked to replace the webview part with a custom player. The player should be capable to handle HLS.
如果我用VideoView和MediaController,我可以玩实况流。但不幸的是,的MediaController有自己的控制。我想我自己的控制和多数民众赞成在我卡住了。
If I use VideoView and MediaController, I can play live stream. But unfortunately, the MediaController has its own controls. I want my own controls and thats where I am stuck.
到目前为止,我尝试:
- 要全部重新编写的MediaController类,并试图改变 布局。它没有工作,因为我不能清除所有的错误 由于依赖关系。
- 在我尝试使用vidtry code(http://github.com/commonsguy/vidtry)的 基准,但没有运气。
- 我试图建立一个扩展的MediaController但didnt类 擦出火花。
- To write the MediaController class all over again and try to change the layout. It didnt work because I could not clear all the errors due to the dependencies.
- I tried using vidtry code (http://github.com/commonsguy/vidtry) for reference but no luck.
- I tried to build a class that extends MediaController but that didnt work either.
我一直在几乎每一个线程上关于#1自定义的媒体播放器,但无法找到的信息让我开始。
是否有可能创建一个自定义的媒体播放器类,而不使用NDK?
如果有人知道如何创建一个自定义的媒体播放器类,请帮助我。
在此先感谢!
I have been in almost every thread on Stackoverflow regarding custom media player but couldnt find information to get me started.
Is it possible to create a custom media player class without using NDK?
If someone knows how to create a custom media player class, please help me.
Thanks in advance!
推荐答案
您可以使用VideoView在它自己并调用它的方法来控制播放,如开始() stopPlayback() 暂停() 简历() seekTo()等。(参见类参考这里: http://developer.android.com/reference/android/widget/VideoView html的)
You could use VideoView on it's own and call it's methods to control playback such as start(), stopPlayback(), pause(), resume(), seekTo() etc. (See class reference here: http://developer.android.com/reference/android/widget/VideoView.html)
刚刚创建的屏幕上的控制,但是你想(按钮/图像),并绑定您的播放控制code code到他们的活动。
Just create your on-screen controls however you want (buttons/images) and bind your playback control code code to their events.
您也想通过在layout.xml取出触摸属性来禁用内置的VideoView控制...
You will also want to disable the inbuilt VideoView controls by removing the touchable property in the layout.xml...
<VideoView
android:id="@+id/myVideoView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false" >
这篇关于在安卓定制的MediaPlayer类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!