1
我使用YouTube播放器API在我的申請,我已經使用了下面的代碼如何在片段中使用YouTubePlayer api?
XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rel1"
android:background="#edeae5">
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtubeplayerview"
android:layout_width="match_parent"
android:layout_height="200dp"/>
</RelativeLayout>
我的活動:
public class EditBloop extends YouTubeBaseActivity implements
YouTubePlayer.OnInitializedListener{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_bloop);
youTubePlayerView = (YouTubePlayerView)findViewById(R.id.youtubeplayerview);
youTubePlayerView.initialize(API_KEY, this);
}
但是在這裏我使用YouTubeBaseActivity,但在我的應用程序我希望youTubePlayer在一個片段。 我該如何做到這一點?我已經看到一些使用YouTubePlayerSupportfragment的鏈接,但我並不理解它們。
請建議。
什麼,我需要在地方YouTubeBaseActivity – user1891910
的延長片段閱讀文檔 – Raghunandan
@ user1891910 https://developers.google。 COM/YouTube的/安卓/播放/參考/ COM /谷歌/安卓/ YouTube的/播放/ YouTubePlayerFragment。擴展'YouTubePlayerFragment',它擴展了'Fragment' – Raghunandan