Android教程视频汇总

来源:互联网 发布:f999b隔墙听淘宝有卖吗 编辑:程序博客网 时间:2024/05/23 21:57

Android教程视频汇总:

(1)第一部:8天快速掌握Android视频。

(2)第二部老罗Android开发视频教程

(3)《Sundy's <Android深入浅出><Android高级应用><Android开发视频教程>》

(4)《Android开发从零开始》系列课程 

(5)李兴华教你Android开发实战

(6)Mars的Android开发视频教程

(7) 黑马程序员Android4.0视频教程

百度网盘下载地址:http://pan.baidu.com/share/link?shareid=3644771642&uk=2570445786
360云盘下载地址:http://yunpan.cn/QX4vB52TFnfbh


http://url.cn/IEYPzR  

 http://t3.qpic.cn/mblogpic/9088bb506dba8eb45c58/2000 http://t.qq.com/p/t/180962016212776


//MusicControl.java

package com.android.internal.policy.impl;



import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.util.Formatter;
import java.util.Locale;
import android.util.Log;
import com.android.internal.R;
import com.android.music.IMediaPlaybackService;    
import android.content.ComponentName;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.widget.*;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.provider.MediaStore;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;


public class MusicControl implements View.OnClickListener, ServiceConnection{
private View musicControlView;  
private RelativeLayout mMusicWidget;
private ImageButton prevSong;
private ImageButton pauseOrPlay;
private ImageButton nextSong; 
private TextView artistName;
private TextView songName;
private TextView trackName;
private TextView mDate;
private IMediaPlaybackService mService;  
private Context mContext;   
private String TAG = "MusicControl";

private final static int REFRESH = 0;
Handler mHandler = new Handler(){


@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case REFRESH:
try {
if(mService != null){  
artistName.setText(mService.getArtistName());
songName.setText(mService.getTrackName());
trackName.setText(mService.getTrackName());
if(mService.isPlaying()){
pauseOrPlay.setImageResource(R.drawable.iphone_stop);
}else{
pauseOrPlay.setImageResource(R.drawable.iphone_play);


} catch (RemoteException e) {
e.printStackTrace();

mHandler.removeMessages(REFRESH);
    mHandler.sendEmptyMessageDelayed(REFRESH, 1000);
break;


default:
break;
}
}

};

public MusicControl(Context context,View musicView) {
Log.d(TAG, "MusicControl Contruct");
mContext = context;
musicControlView = musicView;  
mContext.bindService(new Intent("com.android.music.MediaPlaybackService"), this, Context.BIND_AUTO_CREATE);
 
prevSong = (ImageButton) musicControlView.findViewById(R.id.musicControlPrevious);
pauseOrPlay = (ImageButton) musicControlView.findViewById(R.id.musicControlPlayOrPause);
nextSong = (ImageButton) musicControlView.findViewById(R.id.musicControlNext); 

artistName = (TextView) musicControlView.findViewById(R.id.artist);
songName = (TextView) musicControlView.findViewById(R.id.song_name);
trackName = (TextView) musicControlView.findViewById(R.id.track_name);

prevSong.setOnClickListener(this);
pauseOrPlay.setOnClickListener(this);
nextSong.setOnClickListener(this); 
}
 
    public void startRefresh(){
    mHandler.removeMessages(REFRESH);
    mHandler.sendEmptyMessage(REFRESH);
    }
    public void stopRefresh(){
    mHandler.removeMessages(REFRESH);
    }
public String getMusicTrack() throws RemoteException{
return mService.getTrackName();
    }
    
@Override
public void onClick(View v) { 
if(v == prevSong){
try {
Log.d(TAG, "MusicControl onClick mService:" + mService);
if(mService != null){
mService.prev();

} catch (RemoteException e) { 
e.printStackTrace();
}
}else if(v == pauseOrPlay){
try {
Log.d(TAG, "MusicControl onClick mService:" + mService);
if(mService != null){
if(mService.isPlaying()){
mService.pause();
pauseOrPlay.setImageResource(R.drawable.iphone_play);
}else{
mService.play();
pauseOrPlay.setImageResource(R.drawable.iphone_stop);
}
}

} catch (RemoteException e) { 
e.printStackTrace();
}
}else if(v == nextSong){
Log.d(TAG, "MusicControl onClick mService:" + mService);
try {
if(mService != null){
mService.next();
}

} catch (RemoteException e) { 
e.printStackTrace();
}



@Override
public void onServiceConnected(ComponentName name, IBinder service) { 
Log.d(TAG, "MusicControl onServiceConnected");
mService = IMediaPlaybackService.Stub.asInterface(service);  
}


@Override
public void onServiceDisconnected(ComponentName arg0) { 
mService = null;
}
 
public boolean isMusicPlay(){
Log.d(TAG, "MusicControl isMusicPlay mService:" + mService);
boolean isPlay = false;
if(mService != null){
try {
isPlay = mService.isPlaying();
} catch (RemoteException e) {
Log.d(TAG, "MusicControl isMusicPlay RemoteException");
isPlay = false;
e.printStackTrace();
}
}
return isPlay;
}
}
原创粉丝点击