LoginSignup
3
3

More than 5 years have passed since last update.

iOSアプリで動画をAppleTVに投影する

Posted at

投影方法

AirPlayを利用する

  • AirPlay Overviewの「Provide a Great AirPlay User Experience in Your App」内のリンクを見ると、MPVolumeViewを利用すればAirPlayで接続可能なデバイスのピッカーを表示できる。

    IMG_0094.PNG

  • AppleTVとネットワーク上で繋がっている状態であれば、AppleTVが選択できる。後は、AVPlayerを搭載した画面を作ってあげれば良い。
    IMG_0096.PNG

AirPlayのプロトコル

  • AirPlayの仕様は正式公開されていないがUnofficial AirPlay Protocol Specificationに基づいてHTTPリクエストを送信すれば、AirPlay経由せずに直接投影したりすることもできそう。
  • AllCastとかはAirPlay経由せずに検索や投影ができるが、↑を実装しているんじゃないかと思っています。結局、Appleが正式に公開していない以上、AirPlay利用することを推奨しているのでしょうか。

プレイヤー画面

  • 画面をカスタマイズしない場合は以下のViewControllerを継承した画面を作成すれば良い。
  • AVPlayerを持っているので、コンテンツをうまく紐づけてあげるだけで良い。
  • 再生や停止などの操作も何もしなくてもうまくUIと連動して動作してくれる。

iOS8以上

iOS8未満

画面のカスタマイズ

  • 独自の画面を作成する場合はUIと上手く連動するようにAVPlayerを操作する必要がある。
  • AVPlayer
3
3
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
3
3