Coder Social home page Coder Social logo

bb-coder / dfplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ihoudf/dfplayer

0.0 0.0 0.0 74.72 MB

简单灵活的iOS音频播放器组件。基于AVPlayer,支持本地和远程音频(可断点续传)播放,具有缓存、耳机线控、锁屏和控制中心信息展示、单曲顺序随机播放、airplay播放、歌词同步、记录上次播放进度等音频播放器功能,DFPlayer封装了缓冲条、进度条、播放暂停按钮、下一首按钮、上一首按钮、播放模式按钮、airplay按钮、歌词同步的tableview等UI控件,一行代码布局即可实现相应功能。(!!!歌曲外链已失效,网络音乐暂不能播放)

License: MIT License

Ruby 0.34% Objective-C 99.66%

dfplayer's Introduction

A simple and flexible iOS audio playback module. Based on AVPlayer, support local and remote audio playback, with caching, remote control, locking and control center information display, single sequential and random playback,airplay,Lyrics sync,and other basic audio player functions, using a few code can realize the function of player.(简单又灵活的iOS音频播放组件。基于AVPlayer,支持本地和远程音频播放,具有缓存、耳机线控、锁屏和控制中心信息展示、单曲顺序随机播放、airplay播放、歌词同步、记录上次播放进度等基本的音频播放器功能,DFPlayer封装了缓冲条、进度条、播放暂停按钮、下一首按钮、上一首按钮、播放模式按钮、airplay按钮、歌词同步的tableview等UI控件,一行代码布局即可实现相应功能。)

ps:

(1). Demo中歌曲链接由http://www.kuwo.cn/提供。
(2). 歌曲配图由https://y.qq.com/提供。
(3). 歌词及Lrc制作由http://www.lrcgc.com/https://y.qq.com/提供。

-- 安装(最低支持 iOS 7.0)

手动安装
    1.下载,并将DFPlayer文件夹添加(拖放)到工程
    2.import "DFPlayer.h"
CocoaPods
    1.在 Podfile 中添加:  pod 'DFPlayer'
    2.执行 pod install 或 pod update
    3.import "DFPlayer.h"

DFPLayer使用AFNetworkReachabilityManager进行网络监测,如正在使用AFNetworking,删除DFPlayer中的相关文件。

-- 版本说明

当前版本1.0.5,pods同步。查看更多版本
本次更新:
1.代码解耦
2.增加运行时断点续传
3.改用可扩展的状态码提示
4.播放模式为DFPlayerModeOnlyOnce时,增加下一首(上一首)按钮行为
5.优化歌词同步
6.其他逻辑优化

-- 使用

DFPlayer的使用十分简单。

详细文档:DFPlayer详细文档
简要说明:

1.初始化DFPlayer,设置数据源(必须)

    [[DFPlayer shareInstance] df_initPlayerWithUserId:nil];//初始化
    [DFPlayer shareInstance].dataSource  = self;//设置数据源
    [[DFPlayer shareInstance] df_reloadData];//刷新数据源

2.实现数据源,将音频数据传给DFPlayer(必须)

    //(必须)
    - (NSArray<DFPlayerModel *> *)df_playerModelArray{
        //在这里将音频数据传给DFPlayer
    }

    //(可选)
    - (DFPlayerInfoModel *)df_playerAudioInfoModel:(DFPlayer *)player{
        //DFPlayer收到某个音频的播放请求时,会调用这个方法请求该音频的音频名、歌手、专辑名、歌词、配图等信息。
    }

3.选择AudioId对应的音频加入播放队列准备播放(必须)

    [[DFPlayer shareInstance] df_playerPlayWithAudioId:audioId];

4.选择DFPLayer中提供的UI控件,布局到页面(可选)

DFPlayer封装了歌词tableview(提供逐句和逐字两种模式的基于Lrc的歌词同步)、缓冲条、进度条、播放暂停按钮、下一首按钮、上一首按钮、播放模式按钮(单曲、顺序、随机)、airplay按钮、当前时间Label、总时间Label。

你只需要
(1)同名更换DFPlayer.bundle中的图片
(2)调用DFPlayerControlManager.h中暴露出来的方法,布局到自己的页面,即可实现相应的功能,无需其他代码。

    //使用示例:
    DFPlayerControlManager *manager = [DFPlayerControlManager shareInstance];
    //播放暂停按钮
    [manager df_playPauseBtnWithFrame:frame2 superView:superView block:nil];
    //下一首按钮
    [manager df_nextAudioBtnWithFrame:frame3 superView:superView block:nil];
    //上一首按钮
    [manager df_lastAudioBtnWithFrame:frame4 superView:superView block:nil];
    ...等,详细查看‘详细文档’。

-- 许可证

使用 MIT 许可证,详情见LICENSE 文件。

THANKS!

如果您对DFPlayer有业务需求改进或发现bug,欢迎在这里提交。
您还可以添加qq交流群:479873475 ,一起探讨iOS开发技术,关于DFPlayer的bug修复和版本更新也会在群里及时告知。
合作qq:188816190


English Introduction

-- Installation(required iOS 7.0+)

Manually
    1.Download all the files in the DFPlayer subdirectory.
    2.Add the DFPlayer group to your Xcode project.
    3.import "DFPlayer.h"
CocoaPods
    1.Podfile: pod 'DFPlayer'
    2.Run pod install or pod update.
    3.import "DFPlayer.h"

DFPLayer use AFNetworkReachabilityManager to monitor network status,if you are using AFNetWorking,delete releative file in DFPlayer group.

-- Use

The use of DFPlayer is so easy.

Detailed documentation:DFPlayer documents
Use Statement:
  1. Init DFPlayer,and set dataSource(required)
    [[DFPlayer shareInstance] df_initPlayerWithUserId:nil];
    [DFPlayer shareInstance].dataSource  = self;
    [[DFPlayer shareInstance] df_reloadData];

2.Implement the dataSource method,send data to DFPlayer(required)

    //required
    - (NSArray<DFPlayerModel *> *)df_playerModelArray{
        //send data to DFPlayer
    }

    //optional
    - (DFPlayerInfoModel *)df_playerAudioInfoModel:(DFPlayer *)player{
        //When prepare to play,DFPlayer get audio message like audio name by this method.
    }

3.Start playing(required)

    [[DFPlayerManager shareInstance] df_playerPlayWithAudioId:audioId];

4.Select the method DFPlayer provide,layout your UI(optional)

DFPlayer provide lyrics tableview,buffering bar,progress bar,type button(single circle、order circle、shuffle circle)、play pause button、next audio button、last audio button、current time Label、total time label.

you can
(1)Exchange the image in DFPlayer.bundle with the same name.
(2)Using the method exposed in DFPlayerControlManager.h, layout to your own page, you can achieve the corresponding function, without other code.

    //example:
    DFPlayerControlManager *manager = [DFPlayerControlManager shareInstance];

    //play pause button
    [manager df_playPauseBtnWithFrame:frame2 superView:superView block:nil];

    //next audio button
    [manager df_nextAudioBtnWithFrame:frame3 superView:superView block:nil];
    
    //last audio button
    [manager df_lastAudioBtnWithFrame:frame4 superView:superView block:nil];
    ...

-- License

provided under the MIT license. See LICENSE file for details.


dfplayer's People

Contributors

ihoudf 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.