有没有办法在我的 Android 应用程序中本地播放 Twitch 流视频?我在互联网上找不到任何有关此的信息。
这就是我目前在 WebView (twitch.html) 中打开 twitch 视频的方式:
<a href="https://twitch.tv/'+element.channel.name+'/embed"> ...
但是,当我将设备从垂直视图更改为水平视图时,这会导致一些错误。然后将播放视频声音而不显示视频,等等。
我正在考虑一个解决方法,如果您可以调用它并由 Android 用户在应用程序浏览器中单独打开 twitch-channel,但是如何在我的代码中添加此异常?这是在我的 MainActivity.java 中:
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().equals("www.example.com")) {
// This is my web site, so do not override; let my WebView load the page
return false;
}
// Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
}
它来自官方的 Android 开发者页面,并防止在另一个浏览器应用程序中打开链接。我怎么能为“twitch.tv”添加一个例外?