InteractivePlayerView

介绍:

自定义的音乐播放视图。

运行效果:

使用说明:

Usage(XML)

在xml中定义

 <co.mobiwise.library.InteractivePlayerView
            android:id="@+id/ipv"
            android:layout_width="230dp"
            android:layout_height="230dp"
            app:imageCover="@drawable/imagetest"
            app:emptyColor="#aaffffff"
            app:loadedColor="#fff44336"
            app:selectedAction1="@drawable/shuffle_selected"
            app:selectedAction2="@drawable/like_selected"
            app:selectedAction3="@drawable/replay_selected"
            app:unselectedAction1="@drawable/shuffle_unselected"
            app:unselectedAction2="@drawable/like_unselected"
            app:unselectedAction3="@drawable/replay_unselected" />

找到view并设置必要的值。

InteractivePlayerView ipv = (InteractivePlayerView) findViewById(R.id.ipv);
ipv.setMax(123); // music duration in seconds.
ipv.setOnActionClickedListener(new OnActionClickedListener() {
            @Override
            public void onActionClicked(int id) {
                switch (id){
                    case 1:
                        //Called when 1. action is clicked.
                        break;
                    case 2:
                        //Called when 2. action is clicked.
                        break;
                    case 3:
                        //Called when 3. action is clicked.
                        break;
                    default:
                        break;
                }
            }
        });

开始与停止。

ipv.start();
ipv.stop();

Usage (Java)

ipv.setCoverDrawable(R.drawable.imagetest);
ipv.setActionOneImage(R.drawable.shuffle_selected, R.drawable.shuffle_unselected);
ipv.setActionTwoImage(R.drawable.like_selected, R.drawable.like_unselected);
ipv.setActionThreeImage(R.drawable.replay_selected, R.drawable.replay_unselected);
ipv.setProgressEmptyColor(Color.GRAY);
ipv.setProgressEmptyColor(Color.BLACK);

有用的方法

//Loads image from url (By Picasso)
ipv.setCoverURL(https://img.paonet.com/upload-images-old/a/opensource/2015/0818/_/1.png);
//edit your current progress
ipv.setProgress(12);
int currentProgress = ipv.getProgress();
//Check if any action selected or not. Or edit.
boolean isSelected = ipv.isAction1Selected();
ipv.setAction1Selected(true);
//Check if ipv is playing
ipv.isPlaying();

导入

项目的 build.gradle

repositories {
    maven {
        url "https://jitpack.io"
    }
}

模块的 build.gradle

dependencies {
       compile 'com.github.iammert:InteractivePlayerView:8fd08a6d8b'
}

设计

这里是原型设计

使用到的库

Picasso by Square

已下载
0