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

前端 未结 2 1084
有刺的猬
有刺的猬 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:13

    To achieve two or more youtube players at one activity you need to use YouTubeThumbnailView(It is an ImageView) to show a list of preview images. When the user touch the thumb, you redirect to full screen video player.

    Check out this project.

    0 讨论(0)
  • 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).

    0 讨论(0)
提交回复
热议问题