0

I am trying to write a simple player but on running this code, it throws a NullPointerException.

 try {

            player = Manager.createPlayer("C:\\Users\\Admin\\Desktop\\Movie_0001.3gp");
            player.realize();
            VideoControl vc;
            vc=(VideoControl) player.getControl("VideoControl");
            if(vc!=null){
                Item video=(Item) vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null);
                playerFrm=new Form("playing video");
                playerFrm.append(video);
                display=display.getDisplay(this);
                display.setCurrent(playerFrm);
            }
           player.prefetch();
           player.start();

        }
        catch(IOException ex) {
            ex.printStackTrace();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Henry
  • 91
  • 1
  • 5

2 Answers2

0

display=display.getDisplay seems odd! Was display initialized before and are you overwriting it with a function from its own?

getDisplay probably should be some sort of static function

bharath
  • 14,283
  • 16
  • 57
  • 95
Vincent Koeman
  • 751
  • 3
  • 9
0

you need to change in code Where you get cureent display,

display=Display.getDisplay(this);

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Mr. Sajid Shaikh
  • 7,051
  • 4
  • 21
  • 35