I am working with an streaming android application that works over Ethernet
Lan.


 private MediaPlayer         mMediaPlayer;

public string ipaddr=null;


public void surfaceCreated(SurfaceHolder holder)

{


 ipaddr=getInterfaces();


if(ipaddr!=null)

 {

          try{

                   mMediaPlayer = new MediaPlayer();

                   Uri video = Uri.parse("http://172.24.... :80/video.3gp");
             // *Note : when i enter this URL in browser it starts playing
in mediaplayer*

                    mMediaPlayer.setDataSource(mContext, video);

                    mMediaPlayer.setDisplay(holder);

                    mMediaPlayer.prepare();

                    mMediaPlayer.setOnBufferingUpdateListener(this);

                    mMediaPlayer.setOnCompletionListener(this);

                    mMediaPlayer.setOnPreparedListener(this);

                    mMediaPlayer.setOnVideoSizeChangedListener(this);


 mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

                    mMediaPlayer.setLooping(true);

                 }



                catch (Exception e)

              {

               Log.e(TAG, "error: " + e.getMessage(), e);

              }


  }



else

{


 try{

                   mMediaPlayer = new MediaPlayer();

                   Uri video =
Uri.parse("android.resource://com.myproj.android.MyVideoApp/raw/v10");

                    mMediaPlayer.setDataSource(mContext, video);

                    mMediaPlayer.setDisplay(holder);

                    mMediaPlayer.prepare();

                    mMediaPlayer.setOnBufferingUpdateListener(this);

                    mMediaPlayer.setOnCompletionListener(this);

                    mMediaPlayer.setOnPreparedListener(this);

                    mMediaPlayer.setOnVideoSizeChangedListener(this);


 mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

                    mMediaPlayer.setLooping(true);

                 }


catch (Exception e)

        {

            Log.e(TAG, "error: " + e.getMessage(), e);

        }

}




}




public static String getInterfaces()

 {

try

 {

Enumeration<NetworkInterface> e = NetworkInterface

.getNetworkInterfaces();


while (e.hasMoreElements())

                         {

NetworkInterface ni = e.nextElement();


Enumeration<InetAddress> e2 = ni.getInetAddresses();



                              if (ni.getName().startsWith("eth"))

                                   {

 while (e2.hasMoreElements())

                                          {

InetAddress ip = e2.nextElement();

 if (ip.toString().equalsIgnoreCase("/127.0.0.1"))

                                               {

continue;

                                              }

 return ip.toString();

                                          }

                                    }

                             }

                      }

 catch (Exception e)

 {

e.printStackTrace();

return null;

}


return null;

}




Neither of the video is playing. I am getting
"java.lang.NullPointerException". Whats wrong with the above code?


Any help would be appreciated.



Log File:


E/MyVideoAppView( 1829): error: null

E/MyVideoAppView( 1829): java.lang.NullPointerException

E/MyVideoAppView( 1829): \0x09at
android.media.MediaPlayer.setDataSource(MediaPlayer.java:715)

E/MyVideoAppView( 1829): \0x09at
android.media.MediaPlayer.setDataSource(MediaPlayer.java:692)

E/MyVideoAppView( 1829): \0x09at
com.johnwei.android.MyVideoApp.MyVideoAppView.surfaceCreated(MyVideoAppView.java:66)

E/MyVideoAppView( 1829): \0x09at
android.view.SurfaceView.updateWindow(SurfaceView.java:543)

E/MyVideoAppView( 1829): \0x09at
android.view.SurfaceView.dispatchDraw(SurfaceView.java:348)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.drawChild(ViewGroup.java:1644)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)

E/MyVideoAppView( 1829): \0x09at android.view.View.draw(View.java:6883)

E/MyVideoAppView( 1829): \0x09at
android.widget.FrameLayout.draw(FrameLayout.java:357)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.drawChild(ViewGroup.java:1646)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)

E/MyVideoAppView( 1829): \0x09at android.view.View.draw(View.java:6883)

E/MyVideoAppView( 1829): \0x09at
android.widget.FrameLayout.draw(FrameLayout.java:357)

E/MyVideoAppView( 1829): \0x09at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1862)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewRoot.draw(ViewRoot.java:1522)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewRoot.performTraversals(ViewRoot.java:1258)

E/MyVideoAppView( 1829): \0x09at
android.view.ViewRoot.handleMessage(ViewRoot.java:1859)

E/MyVideoAppView( 1829): \0x09at
android.os.Handler.dispatchMessage(Handler.java:99)

E/MyVideoAppView( 1829): \0x09at android.os.Looper.loop(Looper.java:123)

E/MyVideoAppView( 1829): \0x09at
android.app.ActivityThread.main(ActivityThread.java:3647)

E/MyVideoAppView( 1829): \0x09at
java.lang.reflect.Method.invokeNative(Native Method)

E/MyVideoAppView( 1829): \0x09at
java.lang.reflect.Method.invoke(Method.java:507)

E/MyVideoAppView( 1829): \0x09at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

E/MyVideoAppView( 1829): \0x09at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to