All Projects → changsanjiang → Sjmediacacheserver

changsanjiang / Sjmediacacheserver

Licence: mit
A HTTP Media Caching Framework. It can cache FILE or HLS media. 音视频边播边缓存框架, 支持 HLS(m3u8) 和 FILE(mp4, mp3等).

Projects that are alternatives of or similar to Sjmediacacheserver

Vime
Customizable, extensible, accessible and framework agnostic media player. Modern alternative to Video.js and Plyr. Supports HTML5, HLS, Dash, YouTube, Vimeo, Dailymotion...
Stars: ✭ 1,928 (+2116.09%)
Mutual labels:  audio, player, media, hls
Flutter Assetsaudioplayer
Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
Stars: ✭ 458 (+426.44%)
Mutual labels:  audio, player, mp3, media
React Player
A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion
Stars: ✭ 5,931 (+6717.24%)
Mutual labels:  audio, player, media, hls
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 (+268.97%)
Mutual labels:  cache, audio, player, media
Symphonia
Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Stars: ✭ 191 (+119.54%)
Mutual labels:  audio, mp3, media, mp4
Magicalexoplayer
The Easiest Way To Play/Stream Video And Audio Using Google ExoPlayer In Your Android Application
Stars: ✭ 171 (+96.55%)
Mutual labels:  audio, player, mp4, hls
Mediaelement Files
Sample media files (MP4, WebM, Ogv, MP3, etc.) for the MediaElement.js library
Stars: ✭ 92 (+5.75%)
Mutual labels:  audio, mp3, mp4, hls
Audioplayer
Audio Player for Nextcloud and ownCloud
Stars: ✭ 179 (+105.75%)
Mutual labels:  audio, player, mp3, mp4
Ktvhttpcache
A powerful media cache framework.
Stars: ✭ 2,113 (+2328.74%)
Mutual labels:  cache, audio, player, media
Awesome Video
A curated list of awesome streaming video tools, frameworks, libraries, and learning resources.
Stars: ✭ 397 (+356.32%)
Mutual labels:  audio, player, mp4, hls
Monstercat Visualizer
A real time audio visualizer for Rainmeter similar to the ones used in the Monstercat videos.
Stars: ✭ 571 (+556.32%)
Mutual labels:  audio, player, media
Hysteriaplayer
Objective-C audio player, sitting on top of AVPlayer
Stars: ✭ 568 (+552.87%)
Mutual labels:  audio, player, mp3
Axiom
An FFmpeg GUI for Windows
Stars: ✭ 560 (+543.68%)
Mutual labels:  audio, mp3, mp4
Mediatoolkit
A .NET library to convert and process all your video & audio files.
Stars: ✭ 492 (+465.52%)
Mutual labels:  audio, mp3, mp4
Spotivy
🎼 Download music videos from Spotify playlists
Stars: ✭ 64 (-26.44%)
Mutual labels:  audio, mp3, mp4
Clappr
🎬 An extensible media player for the web.
Stars: ✭ 5,436 (+6148.28%)
Mutual labels:  player, mp4, hls
Ffmpeg
Mirror of https://git.ffmpeg.org/ffmpeg.git
Stars: ✭ 27,382 (+31373.56%)
Mutual labels:  audio, mp4, hls
Wjplayer
Video.js bundle that supports HLS, VAST/VMAP, 360-degree videos, and more.
Stars: ✭ 55 (-36.78%)
Mutual labels:  audio, player, hls
Xamarinmediamanager
Cross platform Xamarin plugin to play and control Audio and Video
Stars: ✭ 647 (+643.68%)
Mutual labels:  audio, player, media
Android P2p Engine
Let your viewers become your unlimitedly scalable CDN.
Stars: ✭ 70 (-19.54%)
Mutual labels:  m3u8, player, hls

SJMediaCacheServer

SJMediaCacheServer is a HTTP Media Caching Framework. It can cache FILE or HLS media.

Features

  • Support cache FILE and HLS media.
  • Support prefetch media.

Installation

pod 'SJUIKit/SQLite3', :podspec => 'https://gitee.com/changsanjiang/SJUIKit/raw/master/SJUIKit-YYModel.podspec'
pod 'SJMediaCacheServer'

使用介绍

Usage

  • Play
#import <SJMediaCacheServer/SJMediaCacheServer.h>

    NSURL *URL = [NSURL URLWithString:@"http://.../auido.mp3"];
    NSURL *playbackURL = [SJMediaCacheServer.shared playbackURLWithURL:URL];
    AVPlayer *player = [AVPlayer playerWithURL:playbackURL];
    [player play];
  • Prefetch
#import <SJMediaCacheServer/SJMediaCacheServer.h>
    
    [SJMediaCacheServer.shared prefetchWithURL:URL preloadSize:20 * 1024 * 1024 progress:^(float progress) {
        NSLog(@"%lf", progress);
    } completed:^(NSError * _Nullable error) {
        NSLog(@"%@", error);
    }];
    
    // The task to cancel the current prefetching.
    id<MCSPrefetchTask> task = [SJMediaCacheServer.shared prefetchWithURL:URL preloadSize:20 * 1024 * 1024 progress:^(float progress) {
        NSLog(@"%lf", progress);
    } completed:^(NSError * _Nullable error) {
        NSLog(@"%@", error);
    }];
    // cancel 
    [task cancel];
  • Download request configuration
    SJMediaCacheServer.shared.requestHandler = ^NSMutableURLRequest * _Nullable(NSMutableURLRequest * _Nonnull request) {
        [request addValue:@"value1" forHTTPHeaderField:@"header filed1"];
        [request addValue:@"value2" forHTTPHeaderField:@"header filed2"];
      return request;
    };
  • Other configuration
    @interface SJMediaCacheServer (Convert)

    /// Resolve the identifier of the resource referenced by the URL.
    ///
    ///     The resource identifier represents a unique resource. When different URLs references the same resource, you can set the block to resolve the identifier.
    ///
    ///     This identifier will be used to identify the local cache. The same identifier will references the same cache.
    ///
    @property (nonatomic, copy, nullable) NSString *(^resolveResourceIdentifier)(NSURL *URL); // URL参数不固定时, 请设置该block返回一个唯一标识符

    /// Encode the received data.
    ///
    ///     This block will be invoked when the download server receives the data, where you can perform some encoding operations on the data.
    ///
    @property (nonatomic, copy, nullable) NSData *(^writeDataEncoder)(NSURLRequest *request, NSUInteger offset, NSData *data); // 对下载的数据进行编码

    /// Decode the read data.
    ///
    ///     This block will be invoked when the reader reads the data, where you can perform some decoding operations on the data.
    ///
    @property (nonatomic, copy, nullable) NSData *(^readDataDecoder)(NSURLRequest *request, NSUInteger offset, NSData *data); // 对读取的数据进行解码

    @end


    @interface SJMediaCacheServer (Log)

    /// Whether to open the console log, only in debug mode. release mode will not generate any logs.
    ///
    ///     If yes, the log will be output on the console. The default value is NO.
    ///
    @property (nonatomic, getter=isEnabledConsoleLog) BOOL enabledConsoleLog; // 是否开启控制日志

    @end


    @interface SJMediaCacheServer (Cache)

    /// The maximum number of resources the cache should hold.
    ///
    ///     If 0, there is no count limit. The default value is 0.
    ///
    ///     This is not a strict limit—if the cache goes over the limit, a resource in the cache could be evicted instantly, later, or possibly never, depending on the usage details of the resource.
    ///
    @property (nonatomic) NSUInteger cacheCountLimit; // 个数限制

    /// The maximum length of time to keep a resource in the cache, in seconds.
    ///
    ///     If 0, there is no expiring limit.  The default value is 0.
    ///
    @property (nonatomic) NSTimeInterval maxDiskAgeForCache; // 保存时长限制

    /// The maximum size of the disk cache, in bytes.
    ///
    ///     If 0, there is no cache size limit. The default value is 0.
    ///
    @property (nonatomic) NSUInteger maxDiskSizeForCache; // 缓存占用的磁盘空间限制

    /// The maximum length of free disk space the device should reserved, in bytes.
    ///
    ///     When the free disk space of device is less than or equal to this value, some resources will be removed.
    ///
    ///     If 0, there is no disk space limit. The default value is 0.
    ///
    @property (nonatomic) NSUInteger reservedFreeDiskSpace; // 剩余磁盘空间限制

    /// Empties the cache. This method may blocks the calling thread until file delete finished.
    ///
    - (void)removeAllCaches; // 删除全部缓存
    @end

License

SJMediaCacheServer is released under the MIT license.

Feedback

Reference

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