Note that there are some explanatory texts on larger screens.

plurals
  1. POOnline Video not Playing
    text
    copied!<p>I'm following a Tutorial to play Video in Android, <a href="http://theandroid.in/play-online-video-example-in-android-device-with-source-code/" rel="nofollow">Tutorial Here</a></p> <p>But when I run the Application on Emulator, it Gives me the following Error</p> <p>MediaPlayer error (1, -2147483648)</p> <p>Please Help</p> <p>Here's the Code of my Application</p> <p>JAVA</p> <pre><code>package com.example.videoplayer; import android.media.MediaPlayer; import android.media.MediaPlayer.OnErrorListener; import android.media.MediaPlayer.OnPreparedListener; import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.Context; import android.graphics.PixelFormat; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.MediaController; import android.widget.ProgressBar; import android.widget.Toast; import android.widget.VideoView; public class MainActivity extends Activity { public static String url = "rtsp://v3.cache8.c.youtube.com/CiILENy73wIaGQmXovF6e-Rf-BMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"; private VideoView videoView = null; private ProgressBar prog = null; private Context ctx = null; private MediaController mediaController = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setFormat(PixelFormat.TRANSLUCENT); setContentView(R.layout.activity_main); ctx = this; prog = (ProgressBar) findViewById(R.id.prog); videoView = (VideoView) findViewById(R.id.video); Uri video = Uri.parse(url); mediaController = new MediaController(this); mediaController.setAnchorView(videoView); videoView.setMediaController(mediaController); videoView.setVideoURI(video); videoView.setOnErrorListener(new OnErrorListener(){ @Override public boolean onError(MediaPlayer mp, int what, int extra) { // TODO Auto-generated method stub Toast.makeText(ctx, "Error occured", 500).show(); return false; } }); videoView.setOnPreparedListener(new OnPreparedListener(){ @Override public void onPrepared(MediaPlayer arg0) { // TODO Auto-generated method stub prog.setVisibility(View.GONE); videoView.start(); } }); } @Override protected void onDestroy(){ try{ videoView.stopPlayback(); } catch(Exception e) { Log.d("MideoPlayer", "Error OnDestroy"); } super.onDestroy(); } } </code></pre> <p>XML</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"&gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;VideoView android:id="@+id/video" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center"/&gt; &lt;ProgressBar android:id="@+id/prog" android:layout_width="70dp" android:layout_height="70dp" android:layout_gravity="center"/&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>and Manifest</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.videoplayer" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.videoplayer.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload