2017-05-28 1 views
1

Je dois afficher une liste de vidéos de YouTube dans mon projet Android. Lorsque je clique sur une vidéo, elle doit démarrer en mode plein écran. J'ai utilisé un WebView comme suggéré dans d'autres sujets avec l'iFrame de html mais l'attribut "allowFullScreen" ne fonctionne pas.L'attribut iFrame allowFullScreen ne fonctionne pas sur Android WebView

J'ai essayé allowFullScreen, allowFullScreen = "true", allowFullScreen = allowFullScreen façons.

String frameVideo = "<html><body><iframe width=\"300\" height=\"300\" src=\"https://www.youtube.com/embed/47yJ2XCRLZs\" scrolling=\"no\" frameborder=\"0\" allowFullScreen=\"allowFullScreen\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\"></iframe></body></html>"; 

    for(int i=0; i<number_of_videos; i++){ 
     video = new WebView(this); 
     video.getSettings().setJavaScriptEnabled(true); 
     video.getSettings().setPluginState(WebSettings.PluginState.ON); 
     video.loadData(frameVideo, "text/html", "utf-8"); 
     video.setWebChromeClient(new WebChromeClient()); 
     video.setId(i); 
     video.setPadding(0, 0, 0, 0); 
     video.setLayoutParams(new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, 900)); 
     root.addView(video); 
    } 

J'éviterais les API YouTube. Aucune suggestion?

Répondre

-1

Au lieu de allowFullScreen = "allowFullScreen" il suffit d'utiliser

<iframe 
width="300" 
height="300" 
src="https://www.youtube.com/embed/47yJ2XCRLZs" 
scrolling="no" 
allowFullScreen > 

allowFullScreen sans valeur