/** 4.分享音乐 */ public void shareMusic(CommonShareMusic shareBean, Object object) { CommonSharePlatform sharePlatform = shareBean.getSharePlatform(); boolean isInstalled = CommonShareUtils.isSupport(mContext, sharePlatform, object); try { if (sharePlatform == CommonSharePlatform.WeixinFriend || sharePlatform == CommonSharePlatform.WeixinFriendCircle) { if (!isInstalled) { Toast.makeText( mContext, mContext.getResources().getString(R.string.share_not_supported), Toast.LENGTH_SHORT) .show(); return; } // 分享至微信好友 mWeixin.shareMusicToWeixin( shareBean.getMusicUrl(), shareBean.getMusicDataUrl(), shareBean.getTitle(), shareBean.getDescription(), shareBean.getBm(), sharePlatform, (IWXAPI) object); } else if (sharePlatform == CommonSharePlatform.QQ_Friend || sharePlatform == CommonSharePlatform.QQ_Weibo || sharePlatform == CommonSharePlatform.QQ_Zone) { mQQ.shareMusic( shareBean.getTitle(), shareBean.getDescription(), shareBean.getAppName(), shareBean.getImgUrl(), shareBean.getMusicUrl(), shareBean.getMusicDataUrl(), sharePlatform, (Tencent) object, null); } } catch (ClassCastException e) { throw new IllegalArgumentException( "object必须传分享目标对象,eg:微信(IWXAPI),QQ(Tencent),微博(IWeiboShareAPI)"); } }
/** 分享音乐至QQ好友 音乐分享后,发送方和接收方在聊天窗口中点击消息气泡即可开始播放音乐。 */ private void shareMusicToQQ( CommonShareMusic shareMusic, Tencent tencent, IUiListener uiListener) { mQQ.shareMusic( shareMusic.getTitle(), shareMusic.getDescription(), shareMusic.getAppName(), shareMusic.getImgUrl(), shareMusic.getTargetUrl(), shareMusic.getMusicUrl(), shareMusic.getSharePlatform(), tencent, uiListener); }