在VideoView中播放来自URL的视频 [Android]
2022-09-01 18:18:18
我发现了类似的问题,但对我没有任何用处。我尝试从这个网址播放视频:
http://videocdn.bodybuilding.com/video/mp4/62000/62792m.mp4
我的java代码:
VideoView videoView= (VideoView)findViewById(R.id.exerciseVideo);
Uri uri = Uri.parse(TEST_URL);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
当我运行应用程序时,活动中不显示任何内容,IDE不显示任何错误。请问,我的想法?
编辑:
我要在哪些地方显示视频的活动:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.martin.fitnessapp.ExerciseDetailActivity"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/exerciseImgA"
android:layout_weight="1"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:paddingRight="8dp"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/exerciseImgB"
android:layout_weight="1"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:paddingLeft="8dp"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="@+id/exerciseDesc" />
<VideoView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/exerciseVideo" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/guideImg"
android:scaleType="fitCenter"
android:adjustViewBounds="true"/>
</LinearLayout>
</ScrollView>