Latest 0.2.0
Homepage https://github.com/sun8801/TTPlayerCache
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit, AVFoundation, SystemConfiguration, MobileCoreServices
Authors

AVPlayer 视频离线缓存、可以边下边播放、部分缓存、断网处理、AVAssetResourceLoaderDelegate

简书地址

CocoaPods

pod ‘TTPlayerCache’, ‘~> 0.2.0’

用法:

#import <TTPlayerCache.h>
...
//把视频播放地址转成系统不能识别的URL
NSString *videoUrl = @"http://....";
BOOL isMP4 = YES; //是否是mp4格式
videoUrl = isMP4? TTResourceUrlFromOrigianllUrl(videoUrl): videoUrl;
...
...
//设置AVPLayer播放
//初始化代理
self.resourceLoaderDelegate = [TTResourceLoaderDelegate new];
self.urlAsset = [AVURLAsset assetWithURL:self.videoURL];
[self.urlAsset.resourceLoader setDelegate:self.resourceLoaderDelegate queue:TT_resourceLoader_delegate_queue()];
...

其他

播放除MP4外的格式时,url不需要转换(现不支持MP4格式外的缓存)

Latest podspec

{
    "name": "TTPlayerCache",
    "version": "0.2.0",
    "summary": "A cache for AVPlayer of TTPlayerCache.",
    "homepage": "https://github.com/sun8801/TTPlayerCache",
    "license": "MIT",
    "authors": {
        "sun": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/sun8801/TTPlayerCache.git",
        "tag": "0.2.0",
        "submodules": true
    },
    "requires_arc": true,
    "frameworks": [
        "UIKit",
        "AVFoundation",
        "SystemConfiguration",
        "MobileCoreServices"
    ],
    "source_files": "Source/TTPlayerCache/TTPlayerCache.h",
    "public_header_files": "source/TTPlayerCache/TTPlayerCache.h",
    "subspecs": [
        {
            "name": "Reachability",
            "source_files": "Source/TTPlayerCache/Reachability/*.{h,m}",
            "public_header_files": "Source/TTPlayerCache/Reachability/*.h"
        },
        {
            "name": "Category",
            "source_files": "Source/TTPlayerCache/Category/*.{h,m}",
            "public_header_files": "Source/TTPlayerCache/Category/*.h"
        },
        {
            "name": "PlayerCache",
            "dependencies": {
                "TTPlayerCache/Category": [],
                "TTPlayerCache/Reachability": []
            },
            "source_files": [
                "Source/TTPlayerCache/TTPlayerCacheMacro.h",
                "Source/TTPlayerCache/TTResourceLoader{Delegate,Data,Cache}.{h,m}"
            ],
            "public_header_files": [
                "Source/TTPlayerCache/TTPlayerCacheMacro.h",
                "Source/TTPlayerCache/TTResourceLoader{Delegate,Data,Cache}.h"
            ]
        }
    ]
}

Pin It on Pinterest

Share This