加载播放器时出错找不到可玩的来源

问题描述 投票:0回答:2

我在我的应用程序中使用WebView。我已经给出了页面的URL,正确加载了网页,但是没有启动流式传输,它显示错误加载播放器。找不到可玩的来源。

怎么解决?

public class MainActivity extends Activity {

    WebView webView;

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webView = (WebView) findViewById(R.id.webView1);
        try {
            WebSettings webSettings = webView.getSettings();
            webSettings.setJavaScriptEnabled(true);
            webView.loadUrl("URL");
        } catch (Exception e) {
            Toast.makeText(getApplicationContext(), "Cannot load page",
                    Toast.LENGTH_SHORT).show();
        }
    }
android android-webview live-streaming
2个回答
0
投票

您可以通过启动用于流式传输视频的特定应用程序来实现此目的。

但是注意:

只有1个合适的视频应用的用户,将无法看到对话框。此外,设置了默认视频应用的用户也不会看到对话框。因此,我不会限制自己,通过启动一个特定的视频应用程序,而是让Android用户有一个很好的Android体验。

如果你有充分的理由推出特定的视频播放器,你可以使用:

try {
    Intent intent = new Intent("com.mxtech.videoplayer.ad"); // Will launch MX player
    intent.setDataAndType(Uri.parse("your_path"), "video/*");
    startActivity(intent);
} catch(ActivityNotFoundException e){
    // the app mxplayer was not found...
    Toast.makeText(this, "mx player is not installed", Toast.LENGTH_SHORT).show();
}

0
投票

指定网址,

 webView.loadUrl(http://stackoverflow.com/questions/22497047/error-loading-player-no-playable-sources-found);

代替,

 webView.loadUrl("URL");
© www.soinside.com 2019 - 2024. All rights reserved.