iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 22
0
Mobile Development

從零開始-30日練習開發iOS APP系列 第 22

從零開始-30日練習開發iOS APP-YouTubeVideo Player Day-22

前言:
如果要加入 YouTube影片 的話,可以在 PodFile 加入這個套件 youtube_ios_player_helper

正文:
方法跟加入 RealmSwift 時一樣
https://ithelp.ithome.com.tw/upload/images/20201005/20129715Jqoypx0cDP.png

成果圖:
https://ithelp.ithome.com.tw/upload/images/20201005/20129715K37ntM1TRJ.png

程式碼:

import UIKit
import youtube_ios_player_helper

class ViewController: UIViewController, YTPlayerViewDelegate {
    //view視窗
    @IBOutlet weak var videoView: YTPlayerView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        videoView.delegate = self
        //加入想播放的網址,取其後段
        //https://www.youtube.com/watch?v=q6EoRBvdVPQ
        videoView.load(withVideoId: "q6EoRBvdVPQ")
        videoView.playVideo()
        
    }
}

上一篇
從零開始-30日練習開發iOS APP-StackView Day-21
下一篇
從零開始-30日練習開發iOS APP-UIPickerView Day-23
系列文
從零開始-30日練習開發iOS APP30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言