17
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Swift】YouTube動画検索&動画再生のサンプルコード(youtube-ios-player-helper)

Last updated at Posted at 2016-11-01

概要

YouTubeの動画検索と動画再生のサンプルコードです。

動画の検索はYouTube Data API (v3) のSearch:listを利用しています。

動画の再生はYouTube Helper Library (youtube-ios-player-helper)
を利用しています。(非常に簡単です!)

PureLayoutを利用し、今回もStoryboardは未使用です。

github

動画再生のコード

// import YouTube Helper Library
import YouTubeiOSPlayerHelper

// view Element
let playerView: YTPlayerView

// initialize
self.playerView = YTPlayerView.newAutoLayoutView()

// addsubview
view.addSubview(playerView)

// Video load
playerView.delegate = self
playerView.loadWithVideoId(video.videoId, playerVars: ["playsinline":1])

// Auto Layout
playerView.autoPinEdgeToSuperviewEdge(.Top)
playerView.autoPinEdgeToSuperviewEdge(.Left)
playerView.autoPinEdgeToSuperviewEdge(.Right)
playerView.autoSetDimension(.Height, toSize: 380)

結果

サンプル

17
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?