how to enable Full screen mode for youtube video embedded in android app
up vote
-1
down vote
favorite
I'm trying to implement YouTube video playing through the accumulation of videos in RecyclerView
.
I'm following it from a certain YouTube video. Although everything is working fine, FULL-SCREEN MODE IS DISABLED.
Don't know the code for enabling full screen. Anyone, please help me?
THE VIDEO IS PLAYING RIGHT IN THE RECYCLER VIEW AND IN THE SAME SIZE.
MainActivity
package com.example.shubhojit.videos;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import java.util.Vector;
public class MainActivity extends AppCompatActivity {
RecyclerView recyclerView;
Vector<YoutubeVideo> youtubeVideos = new Vector<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recycler_Video);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/-uPaSOD7Dvk" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/e8D2eTmHG4I" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/wnHW6o8WMas" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/1LxFtLbreLE" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/jTLghzziZXQ" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/arj7oStGLkU&t=12s" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/7ZkBWN4vW-E" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/dww3Oo8ropA" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/M99NCxR0a-Q" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/Pbb8evErl34" frameborder="0" allowfullscreen></iframe>"));
VideoAdapter videoAdapter = new VideoAdapter(youtubeVideos);
recyclerView.setAdapter(videoAdapter);
}
}
VideoAdapter
package com.example.shubhojit.videos;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import java.util.List;
public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHolder> {
List<YoutubeVideo> youtubeVideoList;
public VideoAdapter() {
}
public VideoAdapter(List<YoutubeVideo> youtubeVideoList) {
this.youtubeVideoList = youtubeVideoList;
}
@NonNull
@Override
public VideoAdapter.VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_item,parent,false);
return new VideoViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull VideoAdapter.VideoViewHolder holder, int position) {
holder.videoWeb.loadData (youtubeVideoList.get(position).getVideoUrl(),"text/html", "utf-8");
}
@Override
public int getItemCount() {
return youtubeVideoList.size();
}
public class VideoViewHolder extends RecyclerView.ViewHolder {
WebView videoWeb;
public VideoViewHolder(View itemView) {
super(itemView);
videoWeb = (WebView) itemView.findViewById(R.id.videoWebView);
videoWeb.getSettings().setJavaScriptEnabled(true);
videoWeb.setWebChromeClient(new WebChromeClient());
}
}
}
YoutubeVideo Model class
package com.example.shubhojit.videos;
public class YoutubeVideo {
private String videoUrl;
public YoutubeVideo() {
}
public YoutubeVideo(String videoUrl) {
this.videoUrl = videoUrl;
}
public String getVideoUrl() {
return videoUrl;
}
public void setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl;
}
}
android
add a comment |
up vote
-1
down vote
favorite
I'm trying to implement YouTube video playing through the accumulation of videos in RecyclerView
.
I'm following it from a certain YouTube video. Although everything is working fine, FULL-SCREEN MODE IS DISABLED.
Don't know the code for enabling full screen. Anyone, please help me?
THE VIDEO IS PLAYING RIGHT IN THE RECYCLER VIEW AND IN THE SAME SIZE.
MainActivity
package com.example.shubhojit.videos;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import java.util.Vector;
public class MainActivity extends AppCompatActivity {
RecyclerView recyclerView;
Vector<YoutubeVideo> youtubeVideos = new Vector<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recycler_Video);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/-uPaSOD7Dvk" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/e8D2eTmHG4I" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/wnHW6o8WMas" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/1LxFtLbreLE" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/jTLghzziZXQ" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/arj7oStGLkU&t=12s" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/7ZkBWN4vW-E" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/dww3Oo8ropA" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/M99NCxR0a-Q" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/Pbb8evErl34" frameborder="0" allowfullscreen></iframe>"));
VideoAdapter videoAdapter = new VideoAdapter(youtubeVideos);
recyclerView.setAdapter(videoAdapter);
}
}
VideoAdapter
package com.example.shubhojit.videos;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import java.util.List;
public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHolder> {
List<YoutubeVideo> youtubeVideoList;
public VideoAdapter() {
}
public VideoAdapter(List<YoutubeVideo> youtubeVideoList) {
this.youtubeVideoList = youtubeVideoList;
}
@NonNull
@Override
public VideoAdapter.VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_item,parent,false);
return new VideoViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull VideoAdapter.VideoViewHolder holder, int position) {
holder.videoWeb.loadData (youtubeVideoList.get(position).getVideoUrl(),"text/html", "utf-8");
}
@Override
public int getItemCount() {
return youtubeVideoList.size();
}
public class VideoViewHolder extends RecyclerView.ViewHolder {
WebView videoWeb;
public VideoViewHolder(View itemView) {
super(itemView);
videoWeb = (WebView) itemView.findViewById(R.id.videoWebView);
videoWeb.getSettings().setJavaScriptEnabled(true);
videoWeb.setWebChromeClient(new WebChromeClient());
}
}
}
YoutubeVideo Model class
package com.example.shubhojit.videos;
public class YoutubeVideo {
private String videoUrl;
public YoutubeVideo() {
}
public YoutubeVideo(String videoUrl) {
this.videoUrl = videoUrl;
}
public String getVideoUrl() {
return videoUrl;
}
public void setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl;
}
}
android
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm trying to implement YouTube video playing through the accumulation of videos in RecyclerView
.
I'm following it from a certain YouTube video. Although everything is working fine, FULL-SCREEN MODE IS DISABLED.
Don't know the code for enabling full screen. Anyone, please help me?
THE VIDEO IS PLAYING RIGHT IN THE RECYCLER VIEW AND IN THE SAME SIZE.
MainActivity
package com.example.shubhojit.videos;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import java.util.Vector;
public class MainActivity extends AppCompatActivity {
RecyclerView recyclerView;
Vector<YoutubeVideo> youtubeVideos = new Vector<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recycler_Video);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/-uPaSOD7Dvk" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/e8D2eTmHG4I" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/wnHW6o8WMas" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/1LxFtLbreLE" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/jTLghzziZXQ" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/arj7oStGLkU&t=12s" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/7ZkBWN4vW-E" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/dww3Oo8ropA" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/M99NCxR0a-Q" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/Pbb8evErl34" frameborder="0" allowfullscreen></iframe>"));
VideoAdapter videoAdapter = new VideoAdapter(youtubeVideos);
recyclerView.setAdapter(videoAdapter);
}
}
VideoAdapter
package com.example.shubhojit.videos;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import java.util.List;
public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHolder> {
List<YoutubeVideo> youtubeVideoList;
public VideoAdapter() {
}
public VideoAdapter(List<YoutubeVideo> youtubeVideoList) {
this.youtubeVideoList = youtubeVideoList;
}
@NonNull
@Override
public VideoAdapter.VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_item,parent,false);
return new VideoViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull VideoAdapter.VideoViewHolder holder, int position) {
holder.videoWeb.loadData (youtubeVideoList.get(position).getVideoUrl(),"text/html", "utf-8");
}
@Override
public int getItemCount() {
return youtubeVideoList.size();
}
public class VideoViewHolder extends RecyclerView.ViewHolder {
WebView videoWeb;
public VideoViewHolder(View itemView) {
super(itemView);
videoWeb = (WebView) itemView.findViewById(R.id.videoWebView);
videoWeb.getSettings().setJavaScriptEnabled(true);
videoWeb.setWebChromeClient(new WebChromeClient());
}
}
}
YoutubeVideo Model class
package com.example.shubhojit.videos;
public class YoutubeVideo {
private String videoUrl;
public YoutubeVideo() {
}
public YoutubeVideo(String videoUrl) {
this.videoUrl = videoUrl;
}
public String getVideoUrl() {
return videoUrl;
}
public void setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl;
}
}
android
I'm trying to implement YouTube video playing through the accumulation of videos in RecyclerView
.
I'm following it from a certain YouTube video. Although everything is working fine, FULL-SCREEN MODE IS DISABLED.
Don't know the code for enabling full screen. Anyone, please help me?
THE VIDEO IS PLAYING RIGHT IN THE RECYCLER VIEW AND IN THE SAME SIZE.
MainActivity
package com.example.shubhojit.videos;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import java.util.Vector;
public class MainActivity extends AppCompatActivity {
RecyclerView recyclerView;
Vector<YoutubeVideo> youtubeVideos = new Vector<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recycler_Video);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/-uPaSOD7Dvk" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/e8D2eTmHG4I" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/wnHW6o8WMas" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/1LxFtLbreLE" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/jTLghzziZXQ" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/arj7oStGLkU&t=12s" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/7ZkBWN4vW-E" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/dww3Oo8ropA" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/M99NCxR0a-Q" frameborder="0" allowfullscreen></iframe>"));
youtubeVideos.add(new YoutubeVideo("<iframe width="100%" height="100%" src="https://www.youtube.com/embed/Pbb8evErl34" frameborder="0" allowfullscreen></iframe>"));
VideoAdapter videoAdapter = new VideoAdapter(youtubeVideos);
recyclerView.setAdapter(videoAdapter);
}
}
VideoAdapter
package com.example.shubhojit.videos;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import java.util.List;
public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHolder> {
List<YoutubeVideo> youtubeVideoList;
public VideoAdapter() {
}
public VideoAdapter(List<YoutubeVideo> youtubeVideoList) {
this.youtubeVideoList = youtubeVideoList;
}
@NonNull
@Override
public VideoAdapter.VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_item,parent,false);
return new VideoViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull VideoAdapter.VideoViewHolder holder, int position) {
holder.videoWeb.loadData (youtubeVideoList.get(position).getVideoUrl(),"text/html", "utf-8");
}
@Override
public int getItemCount() {
return youtubeVideoList.size();
}
public class VideoViewHolder extends RecyclerView.ViewHolder {
WebView videoWeb;
public VideoViewHolder(View itemView) {
super(itemView);
videoWeb = (WebView) itemView.findViewById(R.id.videoWebView);
videoWeb.getSettings().setJavaScriptEnabled(true);
videoWeb.setWebChromeClient(new WebChromeClient());
}
}
}
YoutubeVideo Model class
package com.example.shubhojit.videos;
public class YoutubeVideo {
private String videoUrl;
public YoutubeVideo() {
}
public YoutubeVideo(String videoUrl) {
this.videoUrl = videoUrl;
}
public String getVideoUrl() {
return videoUrl;
}
public void setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl;
}
}
android
android
edited Nov 12 at 3:26
André Sousa
1,1441818
1,1441818
asked Nov 11 at 19:19
Shubhojit Singh
122
122
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252300%2fhow-to-enable-full-screen-mode-for-youtube-video-embedded-in-android-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown