I am French so I'll do my best with my English.
I am working on an Android application that shall catch a 3GP video streaming.
I already have my interface working correctly on my emulator. I am using the SDK 1.0
So here is the error report:
11-22 16:39:40.016: ERROR/OSNetworkSystem(309): unknown socket error -1
11-22 16:39:40.136: ERROR/VideoPlayer(309): unknown error
11-22 16:39:40.136: ERROR/VideoPlayer(309): java.net.SocketException: unknown error
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl(Native Method)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocket(OSNetworkSystem.java:79)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.net.PlainSocketImpl2.create(PlainSocketImpl2.java:59)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at java.net.Socket.checkClosedAndCreate(Socket.java:763)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at java.net.Socket.connect(Socket.java:910)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:61)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:800)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:786)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at demo.java.prototype.setDataSource(prototype.java:156)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at demo.java.prototype.access$2(prototype.java:150)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at demo.java.prototype$5.run(prototype.java:128)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at java.lang.Thread.run(Thread.java:935)
11-22 16:39:40.276: ERROR/MediaPlayer(309): Attempt to call getDuration without a valid mediaplayer
I saw on this forum that I do have to give INTERNET permission. I've done it as well.
Here is a part of my code:
Using java Syntax Highlighting
- private void playVideo() {
- final String path = mPath.getText().toString();
- Log.v(TAG, "path: " + path);
- // If the path has not changed, just start the media player
- if (path.equals(current) && mp != null) {
- mp.start();
- return;
- }
- current = path;
- // Create a new media player and set the listeners
- mp = new MediaPlayer();
- mp.setOnErrorListener(this);
- mp.setOnBufferingUpdateListener(this);
- mp.setOnCompletionListener(this);
- mp.setOnPreparedListener(this);
- mp.setAudioStreamType(2);
- // Set the surface for the video output
- // mp.setDisplay((SurfaceHolder) holder.getSurface());
- // Set the data source in another thread
- // which actually downloads the mp3 or videos
- // to a temporary location
- Runnable r = new Runnable() {
- public void run() {
- try {
- setDataSource(path);
- mp.prepareAsync();
- } catch (IOException e) {
- Log.e(TAG, e.getMessage(), e);
- }
- Log.v(TAG, "Duration: ===>" + mp.getDuration());
- mp.start();
- }
- };
- new Thread(r).start();
- }
- /**
- * If the user has specified a local url, then we download the
- * url stream to a temporary location and then call the setDataSource
- * for that local file
- *
- * @param path
- * @throws IOException
- */
- private void setDataSource(String path) throws IOException {
- if (!URLUtil.isNetworkUrl(path)) {
- mp.setDataSource(path);
- } else {
- URL url = new URL(path);
- URLConnection cn = url.openConnection();
- cn.connect();
- InputStream stream = cn.getInputStream();
- if (stream == null)
- throw new RuntimeException("stream is null");
- File temp = File.createTempFile("mediaplayertmp", "dat");
- String tempPath = temp.getAbsolutePath();
- FileOutputStream out = new FileOutputStream(temp);
- byte buf[] = new byte[128];
- do {
- int numread = stream.read(buf);
- if (numread <= 0)
- break;
- out.write(buf, 0, numread);
- } while (true);
- mp.setDataSource(tempPath);
- try {
- stream.close();
- }
- catch (IOException ex) {
- Log.e(TAG, "error: " + ex.getMessage(), ex);
- }
- }
- }
Parsed in 0.040 seconds, using GeSHi 1.0.8.4
The exception occurs when a do cn.connect();.
I have also give all access to Android emulator with my FireWall....
Does somebody see anything?
Thanks in advance for your help
Gmime




