//变量:
private SeekBar seekbar;
private MediaPlayer player = null;
player = new MediaPlayer();//初始化
seekbarsetMax(playergetDuration());//设进度条显示
//音量:
audioManager=(AudioManager)getSystemService(AUDIO_SERVICE);
int MaxSound=audioManagergetStreamMaxVolume(AudioManagerSTREAM_MUSIC);
maxVolumeTextViewsetText(StringvalueOf(MaxSound));
SoundseekBarsetMax(MaxSound);
int currentSount=audioManagergetStreamVolume(AudioManagerSTREAM_MUSIC);
SoundseekBarsetProgress(currentSount);
SoundseekBarsetOnSeekBarChangeListener(new SeekBarListener());
ProceseekBar2setOnSeekBarChangeListener(new ProcessBarListener());
[Android UI界面]如何实现弧形的进度条或SeekBar? 转载
public MusicSeekbar(Context context, AttributeSet attrs)
{
super(context, attrs);
mContext = context;
mPaintsetAntiAlias(true);
mPaintsetFilterBitmap(true);
mPaintsetStrokeWidth(4);
mPaintsetColor(getResources()getColor(Rcolormusic_seekbar));
mPaintsetStyle(StyleSTROKE);
mBitmapDot = BitmapFactorydecodeResource(getResources(),
Rdrawableui_music_dot);
// if(mThread==null)
// {
// mThread=new Thread(new myThread());
// mThreadstart();
// }
mPaintTextsetAntiAlias(true);
mPaintTextsetStyle(StyleSTROKE);
mPaintTextsetStrokeWidth(1);
// conn=new MediaPlayerServiceConnection(mContext);
// init();
}
protected void onDraw(Canvas canvas) {
mLeft = (float) (Centre_X - RADIUS
Mathcos((90 - mSeekBarTotalDegree / 2 + mDegree) / 180
MathPI));
mTop = (float) (Centre_Y - RADIUS
Mathsin((90 - mSeekBarTotalDegree / 2 + mDegree) / 180
MathPI));
Shader mLinearGradient = new LinearGradient(mLeft - 80, 100, mLeft,
100, new int[] {
getResources()getColor(Rcolormusic_seekbar),
getResources()getColor(Rcolormusic_seekbar1) },
null, ShaderTileModeCLAMP);
mPaintsetShader(mLinearGradient);
canvasdrawArc(mRect, mStartDegree, mDegree, false, mPaint);
canvasdrawBitmap(mBitmapDot, mLeft - 20, mTop - 20, new Paint());
canvassave();
canvasrotate(-22, Centre_X, Centre_Y);
mPaintTextsetColor(getResources()getColor(Rcolormusic_seekbar));
canvasdrawText(formatTime(mCurTime), 150, 0, mPaintText);
canvasrestore();
canvassave();
canvasrotate(20, Centre_X, Centre_Y);
mPaintTextsetColor(ColorWHITE);
canvasdrawText(formatTime(mDuration), 150, 0, mPaintText);
canvasrestore();
superonDraw(canvas);
}
以上就是关于java编写的音乐播放器如何让进度条和音乐关联起来 点击进度条的指定位置 音乐就从指定位置开始播放全部的内容,包括:java编写的音乐播放器如何让进度条和音乐关联起来 点击进度条的指定位置 音乐就从指定位置开始播放、如何实现弧形的进度条或SeekBar、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)