我是新的android开发。我正在使用视频标签。但是,在模拟器上运行视频时,无法播放。尽管视频在浏览器上运行良好。有人可以帮我解决我所缺少的吗?

 <video id="video" autoplay width="500" height="400" controls="controls">
<source src="http://ec2-50-16-201-31.compute-1.amazonaws.com/p/100/sp/10000/flvclipper/entry_id/0_hu1hm4qg" />
not working


 

<script type="text/javascript">
var video = document.getElementById('video');
video.addEventListener('click',function(){
    video.play();
},false);




我也在使用phonegap。
Java代码:App.java

public class App extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/index.html");

    appView.setDownloadListener(new DownloadListener() {
        public void onDownloadStart(String url, String userAgent,
                String contentDisposition, String mimeType, long size) {
            Intent viewIntent = new Intent(Intent.ACTION_VIEW);
            viewIntent.setDataAndType(Uri.parse(url), mimeType);
            try {
                startActivity(viewIntent);
            } catch (ActivityNotFoundException ex) {
                Log.w("YourLogTag",
                        "Couldn't find activity to view mimetype: "
                                + mimeType);
            }
        }
    });
}


}

最佳答案

我不熟悉phoneGap,但您需要在WebView上调用它。 loadUrl(String url)是WebView类的一种方法,因此假设DroidGap类扩展了WebView,则您将调用super.setJavascriptEnabled(true);如果DroidGap实际上并未扩展WebView,而是将在loadUrl中提供的内容传递给了私有对象WebView对象包含在其中,然后使用super将无法正常工作。您将必须找到一种方法来获取对实际用于显示页面的WebView的引用。也许droidGap具有类似.getWebView()之类的东西?

07-24 09:47
查看更多