|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I am developing application with MMAPI. I want to play the video file saved in 3GP. It is not supported by the emulator. So i am directly checking with the Nokia 6600. The video is not visible on the screen. Any one please help in this topic. The file size very is small. My coding is as follows: import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.*; import javax.microedition.media.*; import javax.microedition.media.control.*; import java.io.*; public class PlayVideo extends MIDlet { private Display display; private MyCanvas canvas; private Player player; private VolumeControl vc; private InputStream is; private VideoControl vdc; private HttpConnection connection; private ContentConnection c = null; private DataInputStream dis = null; public PlayVideo() { display = Display.getDisplay(this); canvas = new MyCanvas(this); } protected void startApp() { display.setCurrent(canvas); canvas.setFullScreenMode(true); } protected void pauseApp() { } protected void destroyApp(boolean unconditional) { } class MyCanvas extends Canvas { private PlayVideo playVideo; private int Xposition = 0, Yposition = 0, volume = 30, keyValue = 0, width = 30, count = 0, run = 0, barWidth = 0; private int videoCount = 0, delay = 0, keyValueCopy = 0; private long[] barValue = new long[100]; private long mediaDuration = 0, totalDuration = 0, temp = 0, newDuration = 0, startDuration = 0, firstDuration = 0; private String error, fileFormat = null, filename = null; private Image upImage, downImage; private boolean isPause = true, isMute = false, isOptionTwo = false, isOptionThree = false, isRewindMode = false, isForwardMode = false; private boolean isHTTP = false, isOptionFour = false, isOptionFive = false, isRunning = false, isError = false; public MyCanvas(PlayVideo playVideo) { this.playVideo = playVideo; /* try { upImage = Image.createImage("/up_arrow.png"); downImage = Image.createImage("/dn_arrow.png"); } catch(Exception error) { System.out.println("Error is = "+error); }*/ // thread.start(); } public void setMute() //Setting sound in Mute { try { vc = (VolumeControl) player.getControl("VolumeControl"); vc.setMute(true); } catch (Exception e) { System.out.println("Error in setMute() = "+e); } } public void setUnmute() //Setting sound to ReMute { try { vc = (VolumeControl) player.getControl("VolumeControl"); vc.setMute(false); } catch (Exception e) { System.out.println("Error in setUnmute() = "+e); } } public void playVideoFile(Graphics graphics) //Playing video file from the local path { try { filename = "02.3gp"; fileFormat = TypeOfFile(filename); fileFormat = "video/" + fileFormat; is = getClass().getResourceAsStream(filename);// To play given file from jar file player = Manager.createPlayer(is, fileFormat); player.realize(); vdc = (VideoControl) player.getControl("VideoControl"); if(vdc != null) { vdc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this); vdc.setDisplayLocation(5, 25); //Setting location for video vdc.setVisible(true); //Setting visible player.start(); //Start playing graphics.drawString("Now playing . . .", 5, getHeight()-24, Graphics.LEFT | Graphics.BASELINE); } } catch(Exception e) { error = "Error: "+e; graphics.drawString(error, 5, getHeight()-24, Graphics.LEFT | Graphics.BASELINE); } } public String TypeOfFile(String filename) { String filetype = null; filename = filename.toLowerCase(); int positionFrom = filename.indexOf(".") + 1; int positionTo = filename.length(); String extension = filename.substring(positionFrom, positionTo); //Splitting the string if (extension.equals("mpg")) filetype = "mpeg"; else if (extension.equals("mp3")) filetype = "mp3"; else if (extension.equals("mp4")) filetype = "mp4"; else if (extension.equals("3gp")) filetype = "3gpp"; else if (extension.equals("aac")) filetype = "aac"; else if (extension.equals("wma")) filetype = "x-ms-wma"; else if (extension.equals("mpeg4")) filetype = "mpeg4"; else if (extension.equals("gif")) filetype = "gif"; else if (extension.equals("jts")) filetype = "x-tone-seq"; else if (extension.equals("wav")) filetype = "x-wav"; else if (extension.equals("au")) filetype = "x-au"; else if (extension.equals("amr")) filetype = "x-amr"; else if (extension.equals("awb")) filetype = "amr-wb"; else if (extension.equals("mid")) filetype = "midi"; return filetype; } public void paint(Graphics graphics) { if(keyValue == 51) { playVideoFile(graphics); } } public void keyPressed(int keyCode) { keyValue = keyCode; switch(keyCode) { case 51: repaint(); break; case 35://Exit from the application destroyApp(true); notifyDestroyed(); break; } } }// end of Canvas }// end of MIDLET Regards, G.Dhanalakashmi ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Problem in playing the 3GP in Nokia 6600 mobile... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|