| Reply | « Previous Thread | Next Thread » |
|
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();
}
...
I also tried with an .mpg-file and used: player = Manager.createPlayer(is, "video/mpeg"); |
|
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 |
|
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) {
}
}
|
|
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 |
|
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? |
|
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? |
|
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| 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 |