Android 的全新的 Play Widget

PlayWidget

项目地址: Cleveroad/PlayWidget
简介:適用於 Android 的全新的 Play Widget,由 Cleveroad 提供
您要創建音樂應用嗎?或者,您可以向現有的廣告素材添加一些創意詳情嗎?然後你來到正確的地方!由 Cleveroad 創建的 Android Widget for Android 可以輕鬆地與您的音樂應用程序集成,以便雲端的用戶體驗。打破單調,讓你的音樂播放器獨一無二!
更多: 作者    提 Bug    示例 APK   
标签:
Android- GitHub- Open Source Library- Widget- 音乐播放-

Android 的全新的 Play Widget_第1张图片

Brand new Play Widget for Android by Cleveroad

Are you creating a music app? Or maybe you want to add some creative detail to an existing one? Then you’ve come to the right place! Play Widget for Android created by Cleveroad can be easily integrated with your music app to spruce the user experience up. Break the monotony and make your music player unique!

Take a look at the animation on Play Widget for Android on YouTube in HD quality.

New distinct things encourage users to launch your app again. Add the Play Widget component to your app and enjoy the benefits — it’s easy as one-two-three.

Awesome

Setup and usage

To include this library to your project add dependency in build.gradle file:

    dependencies {
        compile 'com.cleveroad:play-widget:1.0.0'
    }

Use the PlayLayout in layout file


or programmatically

mPlayLayout = new PlayLayout.Builder(context)
                .setLayoutParams(params)
                .setBigDiffuserColorResource(R.color.test_blue)
                .setMediumDiffuserColorResource(R.color.test_green)
                .setBigDiffuserShadowWidthResource(R.dimen.test_dimen_10)
                .setMediumDiffuserShadowWidthResource(R.dimen.test_dimen_10)
                .setSmallDiffuserShadowWidthResource(R.dimen.test_dimen_10)
                .setProgressLinePaddingResource(R.dimen.test_dimen_10)
                .setProgressBallRadiusResource(R.dimen.test_dimen_20)
                .setProgressCompleteLineStrokeWidthResource(R.dimen.test_dimen_10)
                .setProgressLineStrokeWidthResource(R.dimen.test_dimen_20)
                .setProgressLineColorResource(R.color.test_blue)
                .setProgressCompleteColorResource(R.color.test_green)
                .setProgressBallColorResource(R.color.test_red)
                .setDiffusersPaddingResource(R.dimen.test_dimen_30)
                .setButtonsSizeResource(R.dimen.test_dimen_30)
                .setPlayButtonBackgroundTintList(colorStateList)
                .setImageResource(R.drawable.imgpsh_fullsize_hd)
                .build();
        container.addView(playLayout);

methods for changing any settings you can set via attribute in xml:

void setProgressEnabled(boolean enabled)
void setButtonsSize(int buttonsSize)

void setImageBitmap(Bitmap bm)
void setImageURI(@Nullable Uri uri)
void setImageDrawable(@Nullable Drawable drawable)
void setImageResource(@DrawableRes int resId)

void setProgressBallColor(int progressBallColor)
void setProgressCompleteColor(int progressCompleteColor)
void setProgressLineColor(int progressLineColor)

void setProgressBallRadius(float radius)
void setProgressCompleteLineStrokeWidth(float progressCompleteLineStrokeWidth)
void setProgressLineStrokeWidth(float progressLineStrokeWidth)

void setProgressLinePadding(int padding)
void setDiffusersPadding(int padding)

void setBigDiffuserShadowWidth(int bigDiffuserShadowWidth)
void setMediumDiffuserShadowWidth(int mediumDiffuserShadowWidth)
void setSmallDiffuserShadowWidth(int smallDiffuserShadowWidth)

void setBigDiffuserColor(int color)
void setMediumDiffuserColor(int color)
void setPlayButtonBackgroundTintList(@Nullable ColorStateList tint)

To check if diffusers are open use method:

boolean isOpen();

To set progress use method (0.0f - 1.0f):

void setProgress(float progress)

For providing buttons listener use:

void setOnButtonsClickListener(new OnButtonsClickListener() {
    @Override
    public void onShuffleClicked() { }
    @Override
    public void onSkipPreviousClicked() { }
    @Override
    public void onSkipNextClicked() { }
    @Override
    public void onRepeatClicked() { }
    @Override
    public void onPlayButtonClicked() { }
});
void setOnButtonsLongClickListener(new OnButtonsLongClickListener() {
    @Override
    public void onShuffleLongClicked() {}
    @Override
    public void onSkipPreviousLongClicked() {}
    @Override
    public void onSkipNextLongClicked() {}
    @Override
    public void onRepeatLongClicked() {}
    @Override
    public void onPlayButtonLongClicked() {}
});

For providing progress changed listener use:

void setOnProgressChangedListener(new OnProgressChangedListener() {
    @Override
    void onPreSetProgress();
    @Override
    public void onProgressChanged(float progress) {}
});

Method onPreSetProgress will be called when user touch progress line to start changing progress. For changing shadow params you can use method:

void shadowChanged(
    float bigDiffuserShadowPercentage,
    float mediumDiffuserShadowPercentage,
    float smallDiffuserShadowPercentage
);

You can use shadow provider VisualizerShadowChangerVisualizerShadowChanger listen to audio from android system and translate it to diffusers shadow changing. To implement you own data shadow provider, just extend your class from PlayLayout.ShadowPercentageProvider class and use changeShadow method to set new shadow percentages.

protected void changeShadow(
    float bigDiffuserShadowPercentage,
    float mediumDiffuserShadowPercentage,
    float smallDiffuserShadowPercentage
    )

To set shadow provider use:

mPlayLayout.setShadowProvider( VisualizerShadowChanger.newInstance(yourAudioSessionId) );

where yourAudioSessionId is audioSession from MediaPlayer or AudioTrack or 0. For usingVisualizerShadowChanger need to provide permissions:

    
    

Support

If you have any other questions regarding the use of this library, please contact us for support at [email protected] (email subject: "Android PlayWidget widget. Support request.")

你可能感兴趣的:(Android,不错文章转载,android,widget,android)