package com.wwj.sb.domain; /** * 2013/5/7 mp3实体类 * * @author wwj * */ public class Mp3Info{ private long id; // 歌曲ID private String title; // 歌曲名称 private String album; // 专辑 private String artist; // 歌手名称 private long duration; // 歌曲时长 private long size; // 歌曲大小 private String url; // 歌曲路径 private String lrcTitle; // 歌词名称 private String lrcSize; // 歌词大小 public Mp3Info() { super(); } /** * * @param id * @param title * @param album * @param artist * @param duration * @param size * @param lrcTitle * @param lrcSize * @param url */ public Mp3Info(int id, String title, String album, String artist, int duration, int size, String lrcTitle, String lrcSize, String url) { super(); this.id = id; this.title = title; this.album = album; this.artist = artist; this.duration = duration; this.size = size; this.lrcTitle = lrcTitle; this.lrcSize = lrcSize; this.url = url; } @Override public String toString() { return "Mp3Info [id=" + id + ", title=" + title + ", album=" + album + ", artist=" + artist + ", duration=" + duration + ", size=" + size + ", url=" + url + ", lrcTitle=" + lrcTitle + ", lrcSize=" + lrcSize + "]"; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getAlbum() { return album; } public void setAlbum(String album) { this.album = album; } public String getArtist() { return artist; } public void setArtist(String artist) { this.artist = artist; } public long getDuration() { return duration; } public void setDuration(long duration) { this.duration = duration; } public long getSize() { return size; } public void setSize(long size) { this.size = size; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getLrcTitle() { return lrcTitle; } public void setLrcTitle(String lrcTitle) { this.lrcTitle = lrcTitle; } public String getLrcSize() { return lrcSize; } public void setLrcSize(String lrcSize) { this.lrcSize = lrcSize; } }
<RelativeLayout android:id="@+id/ll_player_voice" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/header_layout" android:background="@drawable/player_progresslayout_bg" android:visibility="gone" > <ImageView android:id="@+id/iv_player_min_voice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:background="@drawable/volume_min_icon" /> <ImageView android:id="@+id/iv_player_max_voice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:background="@drawable/volume_max_icon" /> <SeekBar android:id="@+id/sb_player_voice" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@id/iv_player_max_voice" android:layout_toRightOf="@id/iv_player_min_voice" android:background="@drawable/voice_seekbar_bg" android:paddingLeft="5dp" android:paddingRight="5dp" android:progressDrawable="@drawable/voice_seekbar_progress" android:thumb="@drawable/voice_seekbar_thumb" /> </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/voice_seekbar_bg"> </item> <item android:id="@android:id/progress"> <clip android:drawable="@drawable/voice_seekbar_one" /> </item> </layer-list>
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/voice_thumb_press" /> <item android:drawable="@drawable/voice_thumb_normal" /> </selector>
private AudioManager am; //音频管理引用,提供对音频的控制 RelativeLayout ll_player_voice; //音量控制面板布局 int currentVolume; //当前音量 int maxVolume; //最大音量 ImageButton ibtn_player_voice; //显示音量控制面板的按钮 SeekBar sb_player_voice; //控制音量大小 // 音量面板显示和隐藏动画 private Animation showVoicePanelAnimation; private Animation hiddenVoicePanelAnimation;
showVoicePanelAnimation = AnimationUtils.loadAnimation(PlayerActivity.this, R.anim.push_up_in); hiddenVoicePanelAnimation = AnimationUtils.loadAnimation(PlayerActivity.this, R.anim.push_up_out); //获得系统音频管理服务对象 am = (AudioManager)getSystemService(Context.AUDIO_SERVICE); currentVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC); maxVolume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC); sb_player_voice.setMax(maxVolume);
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="200"/> <translate android:fromYDelta="-100%" android:toYDelta="0" android:duration="200"/> </set>
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="200"/> <translate android:fromYDelta="0" android:toYDelta="-100%" android:duration="200"/> </set>
ibtn_player_voice = (ImageButton) findViewById(R.id.ibtn_player_voice); ll_player_voice = (RelativeLayout) findViewById(R.id.ll_player_voice); sb_player_voice = (SeekBar) findViewById(R.id.sb_player_voice);
ibtn_player_voice.setOnClickListener(ViewOnClickListener); sb_player_voice.setOnSeekBarChangeListener(new SeekBarChangeListener());
case R.id.ibtn_player_voice: //控制音量 voicePanelAnimation(); break;
//控制显示音量控制面板的动画 public void voicePanelAnimation() { if(ll_player_voice.getVisibility() == View.GONE) { ll_player_voice.startAnimation(showVoicePanelAnimation); ll_player_voice.setVisibility(View.VISIBLE); } else{ ll_player_voice.startAnimation(hiddenVoicePanelAnimation); ll_player_voice.setVisibility(View.GONE); } }
/** * 实现监听Seekbar的类 * * @author wwj * */ private class SeekBarChangeListener implements OnSeekBarChangeListener { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { switch(seekBar.getId()) { case R.id.audioTrack: if (fromUser) { audioTrackChange(progress); // 用户控制进度的改变 } break; case R.id.sb_player_voice: // 设置音量 am.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0); break; } }