标签:org ade lock 如何使用 ant github mit tps targe
该类包依托于谷歌Mediaplayer二次封装。
谷歌中国API链接:https://developer.android.google.cn/guide/topics/media/mediaplayer.html
支持jcenter方式导入。
支持本地Module方式导入。
dependencies {
compile ‘com.yhd.hdmediaplayer:hdmediaplayer:1.0.1‘
}
include ‘:hdmediaplayer‘
dependencies {
compile project(‘:hdmediaplayer‘)
}
该类支持音乐(.mp3、.wav、.ogg)和视频(.mp4、.3gp)以及对应格式的网络流媒体的播放。
如果要播放视频的话需要控件:SurfaceView。
MediaPlayerHelper.getInstance().setSurfaceView((SurfaceView)findViewById(R.id.surfaceView)).playAsset(MainActivity.this,"test.mp4");
MediaPlayerHelper.getInstance().playAsset(MainActivity.this,"test.mp3");
/**
* urlString 可为网络流媒体连接,也可以为本地存储全路径链接
*/
MediaPlayerHelper.getInstance().setSurfaceView((SurfaceView)findViewById(R.id.surfaceView)).play(urlString);
MediaPlayerHelper.getInstance().setMediaPlayerHelperCallBack(new MediaPlayerHelper.MediaPlayerHelperCallBack() {
@Override
public void onCallBack(MediaPlayerHelper.CallBackState state, MediaPlayerHelper mediaPlayerHelper, Object... args) {
Log.v(TAG,"--"+state.toString());
if(state== MediaPlayerHelper.CallBackState.PROGRESS){
int percent=(int)args[0];
Log.v(TAG,"--progress:"+percent);
}
}
});
/** 设置播放进度回调时间间隔 */
MediaPlayerHelper.getInstance().setProgressInterval(msec);
/** 获得MediaPlayer对象,进行更多的自定义的操作 */
MediaPlayerHelper.getInstance().getMediaPlayer().pause();
MediaPlayerHelper.getInstance().getMediaPlayer().start();
MediaPlayerHelper.getInstance().getMediaPlayer().stop();
欢迎 Star Fork
交流地址:尹海德(123302687@qq.com)
Copyright 2017 Yinhaide
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Android使用MediaPlayer播放流媒体,支持远程以及本地流媒体,一行代码实现
标签:org ade lock 如何使用 ant github mit tps targe
原文地址:http://blog.csdn.net/yinhaide/article/details/71482390