Swift 3.0 Class Note – Video (影片相關)、資料儲存

Presenter : Wei Wei

播放APP內的影片

  • 函式庫:AVFoundation, AVKit
  • 物件:AVPlayer, AVPlayerViewController
  • 設定AVPlayerViewController的屬性
  • 和音樂一樣:
    • 丟入影片檔 -> 找到檔案位置 -> 產生url -> 產生AVPlayer
  • 和音樂不一樣,無法設定循環播放,介紹用Notifiaction,來設定重新播放:videoPlayer?.currentItem?.seek(to: kCMTimeZero)

2016-10-07-14-39-54

git@github.com:dan12411/PlayVideo.git

錄製短片

  • 函式庫:MobileCoreServices, Photos
  • 需加上Privacy : Camera Usage Description, Microphone Usage Description, Photo Library Usage Description
  • 物件:UIImagePickerController
  • Protocol:UIImagePickerControllerDelegate, UINavigationControllerDelegate
  • func :
    • didFinishPickingMediaWithInfo (使用者錄影完後做的事)
    • imagePickerControllerDidCancel (使用者按下Cancel後做的事)

git@github.com:dan12411/HelloRecordVideo.git

拍照

  • 函式庫:MobileCoreServices, Photos
  • 物件:UIImagePickerController
  • Protocol : UIImagePickerControllerDelegate, UINavigationControllerDelegate
  • func :
    • didFinishPickingMediaWithInfo (使用者拍完照後做的事)

ref : AppCoDa

git@github.com:dan12411/HelloTakePhoto.git

資料儲存

  • UserDefaults
    • UserDefaults.standard.set(87, forKey: “yeah") -> 存檔 step1

    • UserDefaults.standard.synchronize() -> 存檔 step2

    • UserDefaults.standard.integer(forKey: “yeah") -> 取檔

    • 如果怕拼錯Key static 變數!!!!!! -> static let myKey = “yeah"

git@github.com:dan12411/HelloUserDefault.git

  • Plist(Property)
    • 產生一Plist檔
    • Set Type : Array or Dictionary
    • Bundle.main.path(forResource: “Score", ofType: “plist") 找路徑
    • 用路徑檔案生出Array(optional) : NSArray

    • more…: Excel to plist 將excel transfer to plist tool

git@github.com:dan12411/HelloPlist.git


發表留言