Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Play Video does not work
    primarykey
    data
    text
    <p>I'm a newbie on android java programming with Eclipse (I have a .NET background) and fail to get a video played in an emulator (nor on an android htc desire)</p> <p>My setup:</p> <ul> <li>Eclipse IDE for Java Developers, Version: Helios Service Release 2</li> <li>Android SDK and ADT Plugin for Eclipse</li> </ul> <p>The video I'm using is a 3gp video I recorded with my htc desire.</p> <p>I have tried the 2 approaches with</p> <ol> <li>VideoView</li> <li>SurfaceView with a MediaPlayer which I took out of the book from Reto Meier "Professional Android 2 Application Development".</li> </ol> <p>I'm targetting Android 2.2 (both in the emulator, as well on my htc desire)</p> <p>Details</p> <p><strong>1. VideoView approach</strong></p> <p>getDuration always returns -1 and even after calling videoView.start() isPlaying is false. Here's the code I'm using:</p> <pre><code>public class MyActivity extends Activity { private static final String FileName = "VIDEO0015.3gp"; private static final String MyTag = "MyActivity"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); VideoView videoView = (VideoView) findViewById(R.id.videoView1); videoView.setKeepScreenOn(true); File clip=new File(Environment.getExternalStorageDirectory(), FileName); if (clip.exists()) { videoView.setVideoPath(clip.getAbsolutePath()); int duration = videoView.getDuration(); if (videoView.canSeekForward()) { videoView.seekTo(duration/2); } videoView.start(); } } } </code></pre> <p>The main.xml file:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;VideoView android:id="@+id/videoView1" android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;/VideoView&gt; &lt;/LinearLayout&gt; </code></pre> <hr> <p><strong>2. SurfaceView with MediaPlayer</strong> With this approach, I get the correct duration (about 15 sec) and isPlaying is true. Both nothing is to be seen and also video playing never is completed.</p> <p>I will add the code if somebody wants to check it.</p> <hr> <p>Thanks for any help, I'm getting desperate.</p> <p>Frank</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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