×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    20

    problems displaying video

    hello,

    for my project i'm using the nokia 6630.
    I would like to display a video
    this the code i wrote (copied form the guide)
    Code:
    /*
     * TestVideo.java
     *
     * Created on 15 juni 2006, 11:46
     */
    
    import javax.microedition.media.control.VideoControl;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import java.io.*;
     
    
    /**
     *
     * @author Gorsken
     */
    public class TestVideo extends MIDlet implements CommandListener {
        
        /** Creates a new instance of testVideo */
        public TestVideo() {
            initialize();
        }
        
        private Form start;
        private Command exit;
        private Command video;
        private Form playVideo;
        private Command stop;
        private Command play;
        private Command Back;
        private Player player;
        
     
    
        /** Called by the system to indicate that a command has been invoked on a particular displayable.
         * @param command the Command that ws invoked
         * @param displayable the Displayable on which the command was invoked
         */
    
        public void commandAction(Command command, Displayable displayable) {
        // Insert global pre-action code here
            if (displayable == playVideo) {
                if (command == Back) {
                    // Insert pre-action code here
                    getDisplay().setCurrent(get_start());
                    // Insert post-action code here
                } else if (command == play) {
                    // Insert pre-action code here
                    playerVideoStart();
                    // Insert post-action code here
                } else if (command == exit) {
                    // Insert pre-action code here
                    exitMIDlet();
                    // Insert post-action code here
                } else if (command == stop) {
                    // Insert pre-action code here
                    playerVideoStop();
                    // Insert post-action code here
                }
            }
        // Insert global post-action code here
        }
    
        /** This method initializes UI of the application.
         */
        private void initialize() {
            // Insert pre-init code here
            getDisplay().setCurrent(get_start());
            // Insert post-init code here
        }
        
        /**
         * This method should return an instance of the display.
         */
        public Display getDisplay() {                         
            return Display.getDisplay(this);
        }                        
     
        /** This method returns instance for exit component and should be called instead of accessing exit field directly.
         * @return Instance for exit component
         */
    
        public Command get_exit() {
            if (exit == null) {
                // Insert pre-init code here
                exit = new Command("Exit", Command.EXIT, 1);
                // Insert post-init code here
            }
            return exit;
        }
    
        /** This method returns instance for video component and should be called instead of accessing video field directly.
         * @return Instance for video component
         */
        public Command get_video() {
            if (video == null) {
                // Insert pre-init code here
                video = new Command("video", Command.OK, 1);
                // Insert post-init code here
            }
            return video;
        }
    
        /** This method returns instance for music component and should be called instead of accessing music field directly.
         * @return Instance for music component
         */
        public Form get_playVideo() {
            if (playVideo == null) {
                // Insert pre-init code here
                playVideo = new Form("playing the video", new Item[0]);
                playVideo.addCommand(get_exit());
                playVideo.addCommand(get_stop());
                playVideo.addCommand(get_play());
                playVideo.addCommand(get_Back());
                playVideo.setCommandListener(this);
                // Insert post-init code here
            }
            return playVideo;
        }
    
        
        /** This method returns instance for stopCommand1 component and should be called instead of accessing stopCommand1 field directly.
         * @return Instance for stopCommand1 component
         */
    
        public Command get_stop() {
            if (stop == null) {
                // Insert pre-init code here
                stop = new Command("Stop", Command.STOP, 1);
                // Insert post-init code here
            }
            return stop;
        }
    
        /** This method returns instance for play component and should be called instead of accessing play field directly.
         * @return Instance for play component
         */
    
        public Command get_play() {
            if (play == null) {
                // Insert pre-init code here
                play = new Command("play", Command.OK, 1);
                // Insert post-init code here
            }
            return play;
        }
    
        public void playerVideoStart(){
            try{
                InputStream is = getClass().getResourceAsStream("/yeti.3gp"); 
                player = Manager.createPlayer(is, "video/3gpp");
                player.realize();
                VideoControl vc = (VideoControl)player.getControl("VideoControl");
                if (vc != null)
                    {
                        Item it =
                        (Item)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE,null);
                        playVideo.append(it);
                        player.start();
                    }
            } catch (IOException ioe) {
            } catch (MediaException me) { }
        }
        
        
         
        
        public void playerVideoStop() throws MediaException{
            player.stop();
            player.close();
        }
    ...
    where is the problem???
    I also tried with an .mpg-file and used:
    player = Manager.createPlayer(is, "video/mpeg");

  2. #2
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: problems displaying video

    Do you get an error message? Or what happens?

    It seems like you have not included the whole source code in here (at least get_start() is missing). Does that method return playVideo form to be displayed?

    Hartti

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    20

    Re: problems displaying video

    nothing happens that is the problem.

    when I press "stop" then it gives: java.lang.NullPointerException

    and yes i did not give everything of the code
    this is de full code:
    Code:
    package Video;
    /*
     * DisplayVideo.java
     *
     * Created on 15 juni 2006, 11:46
     */
    
    import javax.microedition.media.control.VideoControl;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import java.io.*;
     
    
    /**
     *
     * @author Gorsken
     */
    public class DisplayVideo extends MIDlet implements CommandListener {
        
        /** Creates a new instance of testMP3 */
        public DisplayVideo() {
            initialize();
        }
        
        private Form start;
        private Command exit;
        private Command video;
        private Form playVideo;
        private Command stop;
        private Command play;
        private Command Back;
        private Player player;
        
     
    
        /** Called by the system to indicate that a command has been invoked on a particular displayable.
         * @param command the Command that ws invoked
         * @param displayable the Displayable on which the command was invoked
         */
        public void commandAction(Command command, Displayable displayable) {
        // Insert global pre-action code here
            if (displayable == start) {
                if (command == video) {
                    // Insert pre-action code here
                    getDisplay().setCurrent(get_playVideo());
                    // Insert post-action code here
                } else if (command == exit) {
                    // Insert pre-action code here
                    exitMIDlet();
                    // Insert post-action code here
                }
            } else if (displayable == playVideo) {
                if (command == Back) {
                    // Insert pre-action code here
                    getDisplay().setCurrent(get_start());
                    // Insert post-action code here
                } else if (command == play) {
                    // Insert pre-action code here
                    playerVideoStart();
                    // Insert post-action code here
                } else if (command == exit) {
                    // Insert pre-action code here
                    exitMIDlet();
                    // Insert post-action code here
                } else if (command == stop) {
                    // Insert pre-action code here
                    playerVideoStop();
                    // Insert post-action code here
                }
            }
        // Insert global post-action code here
        }
    
        /** This method initializes UI of the application.
         */
        private void initialize() {
            // Insert pre-init code here
            getDisplay().setCurrent(get_start());
            // Insert post-init code here
        }
        
        /**
         * This method should return an instance of the display.
         */
        public Display getDisplay() {                         
            return Display.getDisplay(this);
        }                        
        
        /**
         * This method should exit the midlet.
         */
        public void exitMIDlet() {                         
            getDisplay().setCurrent(null);
            destroyApp(true);
            notifyDestroyed();
        }                        
    
        /** This method returns instance for start component and should be called instead of accessing start field directly.
         * @return Instance for start component
         */
        public Form get_start() {
            if (start == null) {
                // Insert pre-init code here
                start = new Form("go and see video", new Item[0]);
                start.addCommand(get_exit());
                start.addCommand(get_video());
                start.setCommandListener(this);
                // Insert post-init code here
            }
            return start;
        }
    
        /** This method returns instance for exit component and should be called instead of accessing exit field directly.
         * @return Instance for exit component
         */
        public Command get_exit() {
            if (exit == null) {
                // Insert pre-init code here
                exit = new Command("Exit", Command.EXIT, 1);
                // Insert post-init code here
            }
            return exit;
        }
    
        /** This method returns instance for mp3 component and should be called instead of accessing mp3 field directly.
         * @return Instance for mp3 component
         */
        public Command get_video() {
            if (video == null) {
                // Insert pre-init code here
                video = new Command("video", Command.OK, 1);
                // Insert post-init code here
            }
            return video;
        }
    
        /** This method returns instance for music component and should be called instead of accessing music field directly.
         * @return Instance for music component
         */
        public Form get_playVideo() {
            if (playVideo == null) {
                // Insert pre-init code here
                playVideo = new Form("playing the video", new Item[0]);
                playVideo.addCommand(get_exit());
                playVideo.addCommand(get_stop());
                playVideo.addCommand(get_play());
                playVideo.addCommand(get_Back());
                playVideo.setCommandListener(this);
                // Insert post-init code here
            }
            return playVideo;
        }
    
        
        /** This method returns instance for stopCommand1 component and should be called instead of accessing stopCommand1 field directly.
         * @return Instance for stopCommand1 component
         */
        public Command get_stop() {
            if (stop == null) {
                // Insert pre-init code here
                stop = new Command("Stop", Command.STOP, 1);
                // Insert post-init code here
            }
            return stop;
        }
    
        /** This method returns instance for play component and should be called instead of accessing play field directly.
         * @return Instance for play component
         */
        public Command get_play() {
            if (play == null) {
                // Insert pre-init code here
                play = new Command("play", Command.OK, 1);
                // Insert post-init code here
            }
            return play;
        }
    
        /** This method returns instance for Back component and should be called instead of accessing Back field directly.
         * @return Instance for Back component
         */
        public Command get_Back() {
            if (Back == null) {
                // Insert pre-init code here
                Back = new Command("Back", Command.BACK, 1);
                // Insert post-init code here
            }
            return Back;
        }
        
        public void playerVideoStart(){
            try{
                InputStream is = getClass().getResourceAsStream("/rotate.mpg");
                player = Manager.createPlayer(is, "video/mpeg");
                player.realize();
                VideoControl vc = (VideoControl)player.getControl("VideoControl");
                if (vc != null)
                    {
                        Item it =
                        (Item)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE,null);
                        playVideo.append(it);
                        player.start();
                    }
            } catch (IOException ioe) {
            } catch (MediaException me) { }
        }
        
        
         
        
        public void playerVideoStop(){
            player.close();
        }
        
        
        public void startApp() {
        }
        
        public void pauseApp() {
        }
        
        public void destroyApp(boolean unconditional) {
        }
    
         
    }

  4. #4
    Super Contributor
    Join Date
    Mar 2006
    Posts
    516

    Re: problems displaying video

    Hi,

    Please check whether "yeti.3gp" is present in the res folder in the correct path. It might be due to theat the video file is not present or not in the correct path.
    Also unzip the jar and see whether it is in the right path

    Regards,
    Wang

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    20

    Re: problems displaying video

    it is standing in the src directory so i believe it wil be the right one.
    Is there also a limit how big the jar file can be?

  6. #6
    Registered User
    Join Date
    Jun 2006
    Posts
    20

    Re: problems displaying video

    it is standing in the src directory so i believe it wil be the right one.
    Is there also a limit how big the jar file can be?

  7. #7
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: problems displaying video

    So you have checked inside the jar-file (you can do it with Winzip for example) and the video file (yeti, rotate, ...) sits there in the root directory? From your answer I understand that the file is in the file system of your development machine, but that you have not checked inside the jar file. Is that correct?

    Hartti

Similar Threads

  1. Video call problems with Nokia 6680
    By richvdh in forum Streaming and Video
    Replies: 5
    Last Post: 2007-03-23, 22:47
  2. Displaying some text over video
    By moldovan_catalin in forum Symbian Media (Closed)
    Replies: 7
    Last Post: 2006-07-25, 13:55
  3. 6680: Problems displaying video on a call event.
    By Shaikuny in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2006-05-14, 12:57
  4. Question on Displaying Video using Different Classes
    By anxamobile in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2006-02-22, 14:13
  5. 3650 Video playback problems
    By satchmobu in forum Mobile Java General
    Replies: 3
    Last Post: 2003-07-02, 10:17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •