3
votes

Some questions for playing youtube videos in webBrowser component.

  1. I played youtube video in webBrowser component. But it keeps playing when the form is backed as well. It only stops playing when the app is removed. I tried webBrowser.stop() and webBrowser.destroy() method etc in the back command but with no success.

    String getVideoUrl = "https://www.youtube.com/embed/" + videoId + "?autoplay=1";
    WebBrowser player = new WebBrowser();
    player.setURL(getVideoUrl);
    f.addComponent(BorderLayout.CENTER, player);
    

    However webBrowser.reload() solves the problem on android phones but not on Android Tablets.

  2. While viewing the video, if the mobile is set to sleep by the user, the display goes out while watching the video. So how to disable the sleep mode? Mobile screen display out problem.

  3. When the video completes, the youtube video gives video link of the related videos & they can be played too, how can I disable that. I don't want to make other videos play from the app

  4. The video doesn't play in android icecream sandwich and below.

1

1 Answers

0
votes
  1. Try: webBrowser.setPage("<html><head></head><body></body></html>", null);

  2. You can use Display.getInstance().setScreenSaverEnabled(false);.

  3. That's a setting on youtube for embedded links. You can select to disallow it.

  4. That's a limitation of the html embed code from google. Not much we can do here.