Skip to content

Commit 2845c14

Browse files
Update README.md
1 parent b5b55af commit 2845c14

File tree

1 file changed

+37
-9
lines changed

1 file changed

+37
-9
lines changed

README.md

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,51 @@ YouTubePlayerView : The YouTubePlayerView provided by the YouTube SDK comes with
2323

2424
![YouTube Fragment](https://github.com/flipkart-incubator/inline-youtube-view/blob/master/youtube-fragment-android.gif)
2525

26-
## How to use
26+
## How to use ?
2727

2828
Add it in your root build.gradle at the end of repositories :
2929

3030
````java
31-
allprojects {
32-
repositories {
33-
...
34-
maven { url "https://jitpack.io" }
35-
}
31+
allprojects {
32+
repositories {
33+
...
34+
maven { url "https://jitpack.io" }
3635
}
36+
}
3737
````
3838

3939
Add the dependency
4040

4141
````java
42-
dependencies {
43-
compile 'coming_soon'
44-
}
42+
dependencies {
43+
//to be updated soon.
44+
}
45+
````
46+
47+
### YouTubePlayer Activity
48+
49+
Start an YouTubeActivity intent with apiKey and videoId. This will play the youtube video in a new activity in fullscreen mode.
50+
51+
````java
52+
Intent intent = new Intent(MainActivity.this, YouTubeActivity.class);
53+
intent.putExtra("apiKey", Constants.API_KEY);
54+
intent.putExtra("videoId", "3AtDnEC4zak");
55+
startActivity(intent);
56+
````
57+
58+
### YouTubePlayer Inline
59+
60+
Create an instance of YouTubePlayerView inside a fragment. To initialize the player, you need to call the initPlayer method with following params:
61+
1. apiKey
62+
2. videoId
63+
3. webviewUrl : the link to iframe.html file (this is required when the device is not able to render native video, a fallback). By default, use 'https://cdn.rawgit.com/flipkart-incubator/inline-youtube-view/60bae1a1/youtube-android/youtube_iframe_player.html'
64+
4. playerType : native, webview or auto (try native, else fallback to webview)
65+
5. listener : callback listener
66+
6. fragment : fragment hosting this view
67+
7. imageLoader : to load thumbnail image
68+
69+
````java
70+
YouTubePlayerView playerView = new YouTubePlayerView(context);
71+
playerView.initPlayer(Constants.API_KEY, videoId, "https://cdn.rawgit.com/flipkart-incubator/inline-youtube-view/60bae1a1/youtube-android/youtube_iframe_player.html", playerType, listener, fragment, imageLoader);
72+
4573
````

0 commit comments

Comments
 (0)