1 / 6

Android 線上播放 YouTuBe

Android 線上播放 YouTuBe. 建國科技大學 資管系 饒瑞佶 2013/7 V1. Android 線上播放 YouTuBe. 主要透過 Google 提供的 class 需要 YouTuBe 的 video ID 即可 不需要 Google 服務的帳號與密碼. 加入需要的權限. < uses-permission android:name = "android.permission.INTERNET" />

Download Presentation

Android 線上播放 YouTuBe

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Android線上播放YouTuBe 建國科技大學 資管系 饒瑞佶 2013/7 V1

  2. Android線上播放YouTuBe • 主要透過Google提供的class • 需要YouTuBe的video ID即可 • 不需要Google服務的帳號與密碼

  3. 加入需要的權限 <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

  4. layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:text="請輸入youtube影片編號" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/youtubeIdLabel"></TextView> <EditTextandroid:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/youtubeIdText" android:text="@string/defaultYoutubeVideoId"></EditText> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="播放影片" android:id="@+id/viewVideoButton"></Button> </LinearLayout>

  5. onCreate() @Override protectedvoid onCreate(Bundle pSavedInstanceState) { super.onCreate(pSavedInstanceState); setContentView(R.layout.sample); // find vews final TextView videoIdTextView = (TextView) findViewById(R.id.youtubeIdText); final Button viewVideoButton = (Button) findViewById(R.id.viewVideoButton); // 設定按鈕事件 viewVideoButton.setOnClickListener(new View.OnClickListener() { @Override publicvoid onClick(View pV) { String videoId = videoIdTextView.getText().toString(); if(videoId == null || videoId.trim().equals("")){ return; } Intent lVideoIntent = new Intent(null, Uri.parse("ytv://"+videoId), Sample.this, OpenYouTubePlayerActivity.class); startActivity(lVideoIntent); } }); } 呼叫class OpenYouTubePlayerActivity

  6. 其他 Google提供

More Related