TAILIEUCHUNG - iOS 5 Programming Cookbook phần 8

và chắc chắn rằng tập tin tiêu đề thích hợp được nhập khẩu. Thực hiện theo các bước sau để thêm hai khuôn khổ dự án của bạn: 1. Nhấp vào biểu tượng dự án của bạn trong Xcode. 2. Chọn các mục tiêu mà bạn muốn thêm các khuôn khổ, như thể hiện trong Hình 6-1. 3. Bây giờ chọn tab Xây dựng giai đoạn đầu (Hình 6-1). 4. Mở rộng | enumerateGroupsWithTypes ALAssetsGroupAll usingBlock A ALAssetsGroup group BOOL stop __block BOOL foundTheVideo NO group enumerateAssetsUsingBlock A ALAsset result NSUInteger index BOOL stop Get the asset type NSString assetType result valueForProperty ALAssetPropertyType if assetType isEqualToString ALAssetTypeVideo NSLog @ This is a video asset foundTheVideo YES stop YES Get the asset s representation object ALAssetRepresentation assetRepresentation result defaultRepresentation const NSUInteger BufferSize 1024 uint8_t buffer BufferSize NSUInteger bytesRead 0 long long currentOffset 0 NSError readingError nil Find the documents folder an array NSArray documents NSSearchPathForDirectoriesInDomains NSDocumentDirectory NSUserDomainMask YES Retrieve the one documents folder that we need NSString documentsFolder documents objectAtIndex 0 Construct the path where the video has to be saved NSString videoPath documentsFolder stringByAppendingPathComponent @ NSFileManager fileManager NSFileManager alloc init Create the file if it doesn t exist already if fileManager fileExistsAtPath videoPath NO fileManager createFileAtPath videoPath contents nil attributes nil We will use this file handle to write the contents of the media assets to the disk NSFileHandle fileHandle NSFileHandle fileHandleForWritingAtPath videoPath Retrieving Assets from the Assets Library 607 do Read as many bytes as we can put in the buffer bytesRead assetRepresentation getBytes uint8_t buffer fromOffset currentOffset length BufferSize error readingError If we couldn t read anything we will exit this loop if bytesRead 0 break Keep the offset up to date currentOffset bytesRead Put the buffer into an NSData NSData readData NSData alloc initWithBytes const void buffer length bytesRead And write the data to file fileHandle writeData readData while bytesRead 0 NSLog @ Finished reading and storing the video in the documents folder if foundTheVideo stop YES failureBlock A .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.