Giter VIP home page Giter VIP logo

bluetoothmusicsample's Introduction

BluetoothMusicSample

在个人写的音乐播放器API蓝牙连接框架的基础上添加蓝牙连接A2DP进行音乐播放的功能,源码部分并不多,主要是对蓝牙进行A2DP连接。

##当前版本(VERSION) Maven Central

gradle依赖

compile 'com.bandou:a2dp:VERSION'

项目依赖

compile 'org.greenrobot:eventbus:3.0.0'

##使用

====================================
基本方法说明
====================================
//判断A2DP是否连接
if (A2dpManager.getInstance().isConnect()) {
	//连接A2DP
	A2dpManager.getInstance().connect(macAddress);
}
else{
	//断开连接
	A2dpManager.getInstance().destroy();
}

====================================
在Activity或其它地方注册A2dpStatusEvent
EventBus.getDefault().register(this);
====================================

@Subscribe(threadMode = ThreadMode.MAIN)
public void onA2dpStatusEvent(A2dpStatusEvent event) {
    EventBus.getDefault().unregister(this);
    if (event.isSuccess()) {
        Toast.makeText(mContext, "连接a2dp成功", Toast.LENGTH_SHORT).show();
    }
    else{
        Toast.makeText(mContext, "连接a2dp失败", Toast.LENGTH_SHORT).show();
    }
}

更新日志

1.0.1 (2016-8-17)

  • app工程中添加android.permission.BROADCAST_STICKY和android.permission.BIND_ACCESSIBILITY_SERVICE权限
  • 修改library和app工程的编译版本,避免在android6.0以上无法使用的情况,如果有必要大家可以自己添加运行时权限的功能
  • 修改A2DP连接成功时提示连接失败的bug
  • 参考Connecting to a Bluetooth A2DP Device from android

1.0.0 (2016-8-9)

  • 初始化版本

bluetoothmusicsample's People

Contributors

jdhkai avatar alonelytraveler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.