问题
I am building my own view for displaying videos, and I would like to base the custom view on the built-in Android VideoView. I'm therefore looking for the source code to VideoView. Most posts I've found on Stackoverflow and elsewhere point to grepcode. Unfortunately, the code on grepcode doesn't seem to be the code documented on developer.android.com and isn't very usable. For example, the VideoView.java on grepcode references an mContext object which is inherited from View, but not available in the View of the developer.android.com sdk. In addition, the VideoView calls a resume method of MediaPlayer which is also not available in the standard MediaPlayer class. Where can I get the source that is documented on developer.android.com?
Thanks, Vance
回答1:
First of all, Android base framework is open source, there is no difference between the source code from grepcode and the original one from github. They both have pros and cons, source code in grepcode is tagged by API level so easy to navigate specific version of API class, where source code in github have complete change history for every commit, but a bit complex to find/retrieve the early version of specific API class.
the VideoView.java on grepcode references an mContext object which is inherited from View, but not available in the View of the developer.android.com sdk
mContext is marked as @hide
in android.view.View, see head version in github.
the VideoView calls a resume method of MediaPlayer which is also not available in the standard MediaPlayer class.
resume() is marked as @hide
in android.media.MediaPlayer, see earlier version in github or tag 2.2_r1.1 in grepcode.
Generally speaking, the development API (android.jar) that google provides to consumer developer has the com.android.internal
and @hide
APIs stripped off. However, the runtime API (framework.jar) that installed on the actual device has everything.
If you want to use these internal and hide API in your own code, the solution is to use either java reflection or the workaround inazaruk explained in his blog here.
Hope this make sense.
来源:https://stackoverflow.com/questions/11129814/usable-videoview-source-code-for-android-2-2