问题
I'm making an app that plays a video in a videoview as a splash screen. It doesn't work on the emulator and several real phones, it says "Sorry, this video cannot be played.". I have tried a lot of types of videos (all supported according to http://developer.android.com/guide/appendix/media-formats.html), the last I have tried is this: http://download.wavetlan.com/SVV/Media/HTTP/BlackBerry.3gp. I also searched for solution on the internet. But none of them was working. Where is the mistake? My layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/hello_world"
android:src="@drawable/logo" />
<VideoView
android:id="@+id/videoView_circle"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<VideoView
android:id="@+id/videoView_loading"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_below="@+id/videoView_circle"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp" />
</RelativeLayout>
My java:
import android.app.Activity;
import android.os.Bundle;
import android.widget.VideoView;
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
VideoView videoView = (VideoView)findViewById(R.id.videoView_circle);
//MediaController mediaController = new MediaController(this);
// mediaController.setAnchorView(videoView);
//videoView.setMediaController(mediaController);
videoView.setVideoPath("android.resource://com.tamaskoos.tbbt/raw/blackberry");
videoView.start();
}
}
And my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.koostamas.tbbt"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.NoTitleBar" >
<activity
android:name="com.koostamas.tbbt.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.koostamas.tbbt.MainActivity"
android:label="@string/title_activity_main" >
</activity>
</application>
</manifest>
And also here is my logcat:
03-18 18:14:35.659: D/MediaPlayer(348): Couldn't open file on client side, trying server side
03-18 18:14:35.748: E/MediaPlayer(348): error (1, -2147483648)
03-18 18:14:35.860: E/MediaPlayer(348): Error (1,-2147483648)
03-18 18:14:35.860: D/VideoView(348): Error: 1,-2147483648
I'm messing with this for a really long time. I would be very happy if someone could help me. Thanks in advance.
回答1:
1)"Couldn't open file on client side, trying server side"
this message refers that can´t open the file because codecs are not supported or the file doesn´t exist, your file inside the /raw folder must be named "blackberry.3gp
"
2) the package of your app is com.koostamas.tbbt
, not com.tamaskoos.tbbt
that you have defined here:
videoView.setVideoPath("android.resource://com.tamaskoos.tbbt/raw/blackberry");
change the package name to load the video resource:
VideoView videoView = (VideoView)findViewById(R.id.videoView_circle);
videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(Uri.parse("android.resource://com.koostamas.tbbt/" + R.raw.blackberry));
videoView.start();
来源:https://stackoverflow.com/questions/22486460/videoview-on-splash-screen