项目作者: calm

项目描述 :
Stream audio over http, and persist the data to a local file while buffering
高级语言: Objective-C
项目地址: git://github.com/calm/PersistentStreamPlayer.git
创建时间: 2016-10-07T20:58:08Z
项目社区:https://github.com/calm/PersistentStreamPlayer

开源协议:MIT License

下载


PersistentStreamPlayer

Handles the playing of an audio file while streaming, and saves the data to a local URL as soon as the stream completes. Battle-tested in the production version of Calm

Installation

Add this to your Podfile

  1. pod 'PersistentStreamPlayer'

Usage

  1. PersistentStreamPlayer *remoteAudioPlayer = [[PersistentStreamPlayer alloc] initWithRemoteURL:myHTTPURL
  2. localURL:myFileURL];
  3. remoteAudioPlayer.delegate = self;
  4. [remoteAudioPlayer play];

Features

  • streaming of audio file, starting playback as soon as first data is available
  • also saves streamed data to a file URL as soon as the buffer completes
  • simple play, pause and destroy methods (destroy clears all memory resources)
  • ability to seamlessly loop the audio file. call player.looping = YES
  • exposes timeBuffered, helpful for displaying buffer progress bars in the UI
  • handles re-starting the audio file after the buffer stream stalls (e.g. slow network)
  • does not keep audio file data in memory, so that it supports large files that don’t fit in RAM

The PersistentStreamPlayerDelegate protocol has some helpful event indicators, all optional:

  1. /* called when the data is saved to localURL */
  2. - (void)persistentStreamPlayerDidPersistAsset:(PersistentStreamPlayer *)player;
  3. /* called when the audio file completed */
  4. - (void)persistentStreamPlayerDidFinishPlaying:(PersistentStreamPlayer *)player;
  5. /* called when the play head reaches the buffer head */
  6. - (void)persistentStreamPlayerStreamingDidStall:(PersistentStreamPlayer *)player;
  7. /* called as soon as the asset loads with a duration, helpful for showing a duration clock */
  8. - (void)persistentStreamPlayerDidLoadAsset:(PersistentStreamPlayer *)player;
  9. /* on failure to load asset */
  10. - (void)persistentStreamPlayerDidFailToLoadAsset:(PersistentStreamPlayer *)player;