All Projects → StreetVoice → Hysteriaplayer

StreetVoice / Hysteriaplayer

Licence: other
Objective-C audio player, sitting on top of AVPlayer

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Hysteriaplayer

Aplay
A Better(Maybe) iOS Audio Stream、Cache、Play Framework
Stars: ✭ 44 (-92.25%)
Mutual labels:  audio, player, mp3, streaming
Pandoraplayer
🅿️ PandoraPlayer is a lightweight music player for iOS, based on AudioKit and completely written in Swift.
Stars: ✭ 1,037 (+82.57%)
Mutual labels:  audio, player, streaming, cocoapods
Swiftysound
SwiftySound is a simple library that lets you play sounds with a single line of code.
Stars: ✭ 995 (+75.18%)
Mutual labels:  audio, player, cocoapods
Sjmediacacheserver
A HTTP Media Caching Framework. It can cache FILE or HLS media. 音视频边播边缓存框架, 支持 HLS(m3u8) 和 FILE(mp4, mp3等).
Stars: ✭ 87 (-84.68%)
Mutual labels:  audio, player, mp3
Awesome Video
A curated list of awesome streaming video tools, frameworks, libraries, and learning resources.
Stars: ✭ 397 (-30.11%)
Mutual labels:  audio, player, streaming
Fwplayer
A video player SDK for iOS, it is based on AVPlayer. https://se.linkedin.com/in/foks-huiwang, https://fokswang.wixsite.com/home
Stars: ✭ 321 (-43.49%)
Mutual labels:  audio, player, cocoapods
Sbplayerclient
支持全格式的mac版视频播放器
Stars: ✭ 110 (-80.63%)
Mutual labels:  audio, player, mp3
Flutter Assetsaudioplayer
Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
Stars: ✭ 458 (-19.37%)
Mutual labels:  audio, player, mp3
Ktvhttpcache
A powerful media cache framework.
Stars: ✭ 2,113 (+272.01%)
Mutual labels:  audio, player, cocoapods
Musicplayer
A minimal music player built on electron.
Stars: ✭ 145 (-74.47%)
Mutual labels:  audio, player, mp3
React Native Audio Streaming
iOS & Android react native module to play an audio stream, with background support and media controls
Stars: ✭ 753 (+32.57%)
Mutual labels:  audio, player, streaming
Fradioplayer
A simple radio player framework for iOS, macOS, tvOS.
Stars: ✭ 183 (-67.78%)
Mutual labels:  audio, player, cocoapods
Vue Howler
[UNMAINTAINED] A Howler.js mixin for Vue 2 that makes it easy to create custom audio player components
Stars: ✭ 103 (-81.87%)
Mutual labels:  audio, player, mp3
Persistentstreamplayer
Stream audio over http, and persist the data to a local file while buffering
Stars: ✭ 120 (-78.87%)
Mutual labels:  audio, player, streaming
Audioplayer
Audio Player for Nextcloud and ownCloud
Stars: ✭ 179 (-68.49%)
Mutual labels:  audio, player, mp3
Openwhyd
💎 Like Pinterest, for Music
Stars: ✭ 287 (-49.47%)
Mutual labels:  player, mp3, streaming
Mpc Hc
MPC-HC's main repository. For support use our Trac: https://trac.mpc-hc.org/
Stars: ✭ 3,567 (+527.99%)
Mutual labels:  audio, player
React Music Player
🎵 Maybe the best beautiful HTML5 responsive player component for react :)
Stars: ✭ 321 (-43.49%)
Mutual labels:  audio, player
Vgplayer
📺 A simple iOS video player by Vein.
Stars: ✭ 383 (-32.57%)
Mutual labels:  player, cocoapods
Libnyquist
🎤 Cross platform C++11 library for decoding audio (mp3, wav, ogg, opus, flac, etc)
Stars: ✭ 311 (-45.25%)
Mutual labels:  audio, mp3

Hysteria Player

HysteriaPlayer provides useful basic player functionalities.

It provides:

  • PlayerItem cache management.
  • Pre-buffer next PlayerItem.

Features:

  • Supporting both local and remote media.
  • Setting up HysteriaPlayer with few blocks, implementing delegates in your UIView and UIViewController subclasses to update UI when player event changed.
  • Ability to advance next/previous item.
  • If player suspended bacause of buffering issue, auto-resume the playback when buffered size reached 5 secs.
  • Background playable. (check the background audio mode then everything works)
  • Using getHysteriaOrder: to get the index of your PlayerItems.
  • Extends long time buffering in background.
  • Player modes support: Repeat, RepeatOne, Shuffle.

Tutorials

In part 0, what we want? why HysteriaPlayer?

In part 1, demonstrating how to play remote audios with HysteriaPlayer. (version 2.0.0, a little bit outdated. version 2.1.0 modified some APIs)

In part 2, making a simple player user interface.

You can download tutorial source code here

Installation

CocoaPods

If you using CocoaPods, it's easy to install HysteriaPlayer.

Podfile:

platform :ios, 'x.0'

pod 'HysteriaPlayer',			        '~> x.x.x'
    
end

Manually install

Import library to your project

Drag HysteriaPlayer.m, HysteriaPlayer.h to your project.

Add Frameworks

Add CoreMedia.framework, AudioToolbox.framework and AVFoundation.framework to your Link Binary With Libraries.

Copy provided point1sec.mp3 file to your Supporting Files

Ability to play the first PlayerItem when your application is resigned active but first PlayerItem is still buffering.

Background modes for audio playback

Xcode providing GUI checkbox to enable various background modes. Enable Audio and AirPlay, you can find this section from Project -> Capabilities -> Background Modes.

How to use

Delegate, DataSource

Implement HysteriaPlayerDelegate and HysteriaPlayerDataSource in your own playback configurator model. (It can be an UIViewController subclass as well but make it a standalone model makes more sense.)

#import "HysteriaPlayer.h"

@interface ViewController : UIViewController <HysteriaPlayerDelegate, HysteriaPlayerDataSource>

There are 4 optional delegates in HysteriaPlayerDelegate:

@optional
- (void)hysteriaPlayerWillChangedAtIndex:(NSUInteger)index;
- (void)hysteriaPlayerCurrentItemChanged:(AVPlayerItem *)item;
- (void)hysteriaPlayerRateChanged:(BOOL)isPlaying;
- (void)hysteriaPlayerDidReachEnd;
- (void)hysteriaPlayerCurrentItemPreloaded:(CMTime)time;
- (void)hysteriaPlayerDidFailed:(HysteriaPlayerFailed)identifier error:(NSError *)error;
- (void)hysteriaPlayerReadyToPlay:(HysteriaPlayerReadyToPlay)identifier;

3 optional delegates in HysteriaPlayerDataSource:

@optional
- (NSUInteger)hysteriaPlayerNumberOfItems;
- (NSURL *)hysteriaPlayerURLForItemAtIndex:(NSUInteger)index preBuffer:(BOOL)preBuffer;
- (void)hysteriaPlayerAsyncSetUrlForItemAtIndex:(NSUInteger)index preBuffer:(BOOL)preBuffer;

If you don't implement hysteriaPlayerNumberOfItems delegate method, you have to set itemsCount property to HysteriaPlayer.

And you must implement one of hysteriaPlayerURLForItemAtIndex:preBuffer or hysteriaPlayerAsyncSetUrlForItemAtIndex:preBuffer delegate method.

Setup

...

- (void)setupHyseteriaPlayer
{
    HysteriaPlayer *hysteriaPlayer = [HysteriaPlayer sharedInstance];
    hysteriaPlayer.delegate = self;
    hysteriaPlayer.datasource = self;
}

- (NSUInteger)hysteriaPlayerNumberOfItems
{
    return self.itemsCount;
}

- (NSURL *)hysteriaPlayerURLForItemAtIndex:(NSUInteger)index preBuffer:(BOOL)preBuffer
{
    return [[NSURL alloc] initFileURLWithPath:[localMedias objectAtIndex:index]];
}

Snippets

Get item's index of my working items:

HysteriaPlayer *hysteriaPlayer = [HysteriaPlayer sharedInstance];
NSNumber *order = [hysteriaPlayer getHysteriaOrder:[hysteriaPlayer getCurrentItem]];

Get playing item's timescale

HysteriaPlayer *hysteriaPlayer = [HysteriaPlayer sharedInstance];
NSDictionary *dict = [hysteriaPlayer getPlayerTime];
double durationTime = [[dict objectForKey:@"DurationTime"] doubleValue];
double currentTime = [[dict objectForKey:@"CurrentTime"] doubleValue];

Get Player status

switch ([hysteriaPlayer getHysteriaPlayerStatus]) {
    case HysteriaPlayerStatusUnknown:
        
        break;
    case HysteriaPlayerStatusForcePause:
        
        break;
    case HysteriaPlayerStatusBuffering:
        
        break;
    case HysteriaPlayerStatusPlaying:
        
    default:
        break;
}

Disable played item caching

Default is cache enabled

HysteriaPlayer *hysteriaPlayer = [HysteriaPlayer sharedInstance];
[hysteriaPlayer enableMemoryCached:NO];

What if I don't need player instance anymore?

HysteriaPlayer *hysteriaPlayer = [HysteriaPlayer sharedInstance];
[hysteriaPlayer deprecatePlayer];
hysteriaPlayer = nil;

Known Issues

If you going to play HTTP Live streaming on iOS 8 and below. (iOS 9+ is fine, no worries)
There's a property you had to set at very first time when HysteriaPlayer is initiated.

HysteriaPlayer *hysteriaPlayer = [HysteriaPlayer sharedInstance];
hysteriaPlayer.skipEmptySoundPlaying = YES;

Licenses

All source code is licensed under the MIT License.

Author

Created by Saiday

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].