You Are Here:

Community: Developer Discussion Boards

#1 Old problems displaying video - 2006-06-20, 11:07

Join Date: Jun 2006
Posts: 20
gorsken
Offline
Registered User
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");
Reply With Quote

#2 Old Re: problems displaying video - 2006-06-20, 18:39

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
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
Reply With Quote

#3 Old Re: problems displaying video - 2006-06-20, 19:14

Join Date: Jun 2006
Posts: 20
gorsken
Offline
Registered User
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) {
    }

     
}
Reply With Quote

#4 Old Re: problems displaying video - 2006-06-20, 19:50

Join Date: Mar 2006
Posts: 518
wang_shui
Offline
Super Contributor
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
Reply With Quote

#5 Old Re: problems displaying video - 2006-06-21, 13:24

Join Date: Jun 2006
Posts: 20
gorsken
Offline
Registered User
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?
Reply With Quote

#6 Old Re: problems displaying video - 2006-06-21, 13:58

Join Date: Jun 2006
Posts: 20
gorsken
Offline
Registered User
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?
Reply With Quote

#7 Old Re: problems displaying video - 2006-06-21, 18:18

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
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
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Video call problems with Nokia 6680 richvdh Streaming and Video 5 2007-03-23 23:47
Displaying some text over video moldovan_catalin Symbian Media (Graphics & Sounds) 7 2006-07-25 14:55
6680: Problems displaying video on a call event. Shaikuny Symbian Media (Graphics & Sounds) 0 2006-05-14 13:57
Question on Displaying Video using Different Classes anxamobile Mobile Java Media (Graphics & Sounds) 1 2006-02-22 15:13
3650 Video playback problems satchmobu Mobile Java General 3 2003-07-02 11:17

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ