我想在我的网页浏览中加载YouTube视频。这就是我这样做的方式
st = 10,en = 20是开始和结束秒数(此YouTube视频将播放10秒,结束时间为20秒)
我的代码:
的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >
<WebView
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:background="#000000"
android:id="@+id/webview1" />
</RelativeLayout>
代码:
mWebview=(WebView)findViewById(R.id.webview1);
mWebview.getSettings().setJavaScriptEnabled(true);
mWebview.getSettings().setPluginsEnabled(true);
Log.e("Status", "tried url");
mWebview.loadUrl(videoPath);
mWebview.setWebChromeClient(new WebChromeClient());
这里我给出了startseconds为10和endseconds为20,它在系统浏览器中运行良好。 但是在进入Android默认浏览器时,只有endseconds正在运行。
我的视频播放时间为0秒,尽管我已经开始= 10秒。我认为这是Youtube api的一个错误。 我想知道如何解决这个问题。