vendredi 27 juin 2014

Best way to play videos in Android?


Vote count:

0




I have deve loped an app to watch embed videos. I play them with a webview but is not efficent for this...


I have hardwareAccelerated = true in mi AndroidManisfest file but it keeps 'lagging'.


I can't use YouTube API (I know is a good API to watch videos) because my videos are not in Youtube and i cannot upload it due to copyright therms.


So, is any other good API to play videos in an Android app? I'm using a WebChromeClient... or some suggestions to improve the WebView efficiency?


This is my webView



webViewPlayer = (WebView) findViewById(R.id.youtubeplayerview);
webViewPlayer.getSettings().setJavaScriptEnabled(true);
webViewPlayer.getSettings().setAppCacheEnabled(true);
webViewPlayer.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webViewPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webViewPlayer.getSettings().setDomStorageEnabled(true);
webViewPlayer.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// This line right here is what you're missing.
// Use the url provided in the method. It will match the member URL!
webViewPlayer.loadUrl(url);
return true;
}

@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
Toast.makeText(cntx, getString(R.string.toast_loaded), Toast.LENGTH_SHORT).show();
super.onPageFinished(view, url);
}


});
mClient = new MyChromeClient();
webViewPlayer.setWebChromeClient(mClient);


P.D. Launch the browser with an embed video is not a solution for me because my webView is a part of the activity, isn't fullscreen.


Thanks in advance.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire