iOS M3U8視訊的下載與播放
阿新 • • 發佈:2019-02-15
//// AppDelegate.m// TestM3U8//// Created by on 14-3-14.// Copyright (c) 2014年 .
All rights reserved.//#import "AppDelegate.h"
#define kPathDownload @"Downloads"@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// m3u8 檔案下載好之後,得搭建本地伺服器 httpServer = [[HTTPServer alloc] init];
// 設定伺服器型別為tcp
[httpServer setType:@"_http._tcp."];
// 設定本地伺服器埠號,你可以隨意設定埠號
[httpServer setPort:12345];
NSString *pathPrefix = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0];
NSString *webPath = [pathPrefix stringByAppendingPathComponent:kPathDownload];
NSLog(@"Setting document root: %@", webPath);
// 指定本地伺服器播放的檔案路徑
[httpServer setDocumentRoot:webPath];
NSError *error;
if(![httpServer start:&error])
{
NSLog(@"Error starting HTTP Server: %@", error);
}
// Override point for customization after application launch. return YES;
}
#define kPathDownload @"Downloads"@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// m3u8
// 設定伺服器型別為tcp
[httpServer setType:@"_http._tcp."];
// 設定本地伺服器埠號,你可以隨意設定埠號
[httpServer setPort:12345];
NSString *pathPrefix = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0];
NSLog(@"Setting document root: %@", webPath);
// 指定本地伺服器播放的檔案路徑
[httpServer setDocumentRoot:webPath];
NSError *error;
if(![httpServer start:&error])
{
NSLog(@"Error starting HTTP Server: %@", error);
}
// Override point for customization after application launch.
}