⭐️ 利用 iOS SDK 各式型別生成東西,設定它的屬性和呼叫方法

//播音樂
import AVFoundation

let url = URL(string: "http://www.kaigai.com.tw/news/Google&QumQum.mp4")
let player = AVPlayer(url: url!)
player.play()
player.currentTime()
player.pause()

//播影片 這裡比較奇怪,影片播個幾秒就停了,要請peter pan解惑
import AVKit
import PlaygroundSupport

let url = URL(string: "http://www.kaigai.com.tw/news/Google&QumQum.mp4")
let player = AVPlayer(url: url!)
let controller = AVPlayerViewController()
controller.player = player
PlaygroundPage.current.liveView = controller
player.play()

//開網頁
import SafariServices
import PlaygroundSupport

let url = URL(string: "https://www.kaigai.com.tw")
let controller = SFSafariViewController(url: url!)
PlaygroundPage.current.liveView = controller

//開地圖秀台北101,台北世貿中心
import MapKit
import PlaygroundSupport

let mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
mapView.region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 25.033642, longitude: 121.564740), latitudinalMeters: 1000, longitudinalMeters: 1000)
PlaygroundPage.current.liveView = mapView
let bigBenAnnotation = MKPointAnnotation()
bigBenAnnotation.title = "台北101"
bigBenAnnotation.coordinate = CLLocationCoordinate2D(latitude: 25.033642, longitude: 121.564740)
bigBenAnnotation.subtitle = "台北的跨年好去處"
mapView.addAnnotation(bigBenAnnotation)
let londonEyeAnnotation = MKPointAnnotation()
londonEyeAnnotation.title = "台北世貿中心"
londonEyeAnnotation.coordinate = CLLocationCoordinate2D(latitude: 25.033700, longitude: 121.562423)
londonEyeAnnotation.subtitle = "台北的看展好去處"
mapView.addAnnotation(londonEyeAnnotation)
mapView.mapType = .hybrid

//顯示時間,取得星期幾跟年份
import Foundation

let today = Date()
let dateComponents = Calendar.current.dateComponents(in: TimeZone.current, from: today)
let month = dateComponents.month
let day = dateComponents.day
//weekday數值1是星期天
let weekday = dateComponents.weekday
let year = dateComponents.year

//使用內建合成器說話
import AVFAudio

let utterance = AVSpeechUtterance(string: "就是開不了口,讓她知道。我一定會呵護著妳,也逗妳笑。")
utterance.voice = AVSpeechSynthesisVoice(language: "zh-TW")
utterance.rate = 0.5
utterance.pitchMultiplier = 1.0
let synthesizer = AVSpeechSynthesizer()
synthesizer.speak(utterance)

--

--