Android youtube API play two or more Youtube players in one main activity

前端 未结 2 1083
有刺的猬
有刺的猬 2021-02-14 12:32

Using the Android Youtube api i want to play two videos in my app main activity without using fragment we have the same problem with this Multiple Youtube players in one activi

2条回答
  •  庸人自扰
    2021-02-14 13:15

    Maybe trivial answer. But is for your use-case acceptable to call init of second youtube player from success callback of the first one? Have you tried it? It should be a reasonable workaround.

    But there might be a catch that is extending YouTubeBaseActivity I looked up documentation, and it looks like there can be only one YouTubeView per activity because of binding between them.

    So I can offer another advice, use YouTubePlayerFragment or SupportYouTubePlayerFragment instead. It should have its own lifecycle (not tested).

提交回复
热议问题