Giter VIP home page Giter VIP logo

cyaudiostream's Introduction

CYAudioStream

  CYAudioStream是基于开源框架FreeStreamer封装的流媒体播放器。在FreeStreamer的基础上优化了播放、缓冲进度等事件的回调方式,CYMusicPlayer封装了基本的列表播放业务,简单易用。

Features

  • 支持音频格式等基本特性请查看FreeStreamer
  • 支持在线音频边存边播
  • 支持后台播放
  • 支持耳机、锁屏远程事件响应
  • 支持播放列表管理

Installation

将CYAudioStream文件夹拖拽至工程目录下,在build phases中导入依赖库:

  • UIKit.framework
  • libxml2.tbd
  • AVFoundation.framework
  • AudioToolBox.framework
  • CFNetworking.framework
  • MediaPlayer.framework
  • FreeStreamer.framework

为了防止编译通过后运行时报“image not found”找不到镜像的错误,需要在build phases中新建一个copy file phase

这里写图片描述

注意: demo中默认的FreeStreamer.Framework是由lipo命令合成的真机+模拟器动态库,方便开发阶段使用模拟器调试,打包时请手动将其替换为iphones_freestream目录下的真机动态库

Usage

使用时,导入CYMusicPlayer,

#import "CYMusicPlayer.h"

然后通过CYMusicPlayer单例方法创建音乐播放器,并设置播放列表使用即可,

    self.player = [CYMusicPlayer sharedPlayer];
    self.player.audioStream.delegate = self;
    
    CYAudioStreamModel *model0 = [[CYAudioStreamModel alloc] init];
    model0.sourceUrl = _music0Url;
    model0.title = @"music0";
    [self.player.playList addObject:model0];
    
    CYAudioStreamModel *model1 = [[CYAudioStreamModel alloc] init];
    model1.sourceUrl = _videoUrl0;
    model1.title = @"music1";
    [self.player.playList addObject:model1];
    
    [self.player play];

播放进度等回调播放相关回调由CYAudioStreamDelegate提供,

@protocol CYAudioStreamDelegate <NSObject>

@optional

- (void)CYAudioStreamPlayingDidCompleted:(CYAudioStream *)audioStream;

- (void)CYAudioStreamPlayingDidFailed:(CYAudioStream *)audioStream;
 
- (void)CYAudioStream:(CYAudioStream *)audioStream playPositionDidChange:(CYAudioStreamPosition)position;

- (void)CYAudioStream:(CYAudioStream *)audioStream bufferProgressDidChange:(CGFloat)progress;

- (void)CYAudioStream:(CYAudioStream *)audioStream stateDidChange:(CYAudioStreamState)state;

@end

CYRemoteControlObserver会自动监听和处理远程控制事件,如需后台播放,须在capabilities中对Background Modes进行设置。

这里写图片描述

cyaudiostream's People

Contributors

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