1. 程式人生 > >iOS M3U8視訊的下載與播放

iOS M3U8視訊的下載與播放

////  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;
}