I'm trying to create an app in which user can play In-App videos (videos already packaged in the application). No SDCard
or Online streaming is going on.
But no matter what strategy I use I'm not able to run a simple .mp4
video in my app.
I've tried placing video in assests
folder but no luck.
I've tried placing video in res/raw
folder, again no luck.
Every time I run the app it says - Cannot play this video.
Earlier I when used just VideoView
to run the video, now I'm using MediaController
along with VideoView
the error message keeps coming
Please help as it's troubling for quite some time and no matter what solution I use, I'm still unable to run a simple video.
My Activity code:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MediaController mediac;
VideoView video1;
mediac = new MediaController(this);
video1 = (VideoView) findViewById(R.id.vv01);
video1.setMediaController(mediac);
mediac.setAnchorView(video1);
video1.setVideoURI(Uri.parse("android.resource://com.example.test/raw/aa"));
video1.start();
}
My xml file:
<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" >
<VideoView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/vv01"
android:contentDescription="@string/app_name"
/>
</LinearLayout>
The log cat when I try to run the application:
08-26 13:27:31.023: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:31.593: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:31.643: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:31.913: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:31.923: D/dalvikvm(624): GC_CONCURRENT freed 147K, 3% free 9345K/9607K, paused 7ms+7ms
08-26 13:27:32.053: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:32.083: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:32.533: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:32.564: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:33.033: I/dalvikvm(624): threadid=3: reacting to signal 3
08-26 13:27:33.063: I/dalvikvm(624): Wrote stack traces to '/data/anr/traces.txt'
08-26 13:27:33.613: D/MediaPlayer(624): getMetadata
08-26 13:27:33.973: E/MediaPlayer(624): error (1, -2147483648)
08-26 13:27:34.093: E/MediaPlayer(624): Error (1,-2147483648)
08-26 13:27:34.093: D/VideoView(624): Error: 1,-2147483648