Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 5th, 2007, 05:28 AM
dhana_gana dhana_gana is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 6 dhana_gana User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 12 m 51 sec
Reputation Power: 0
Question Problem in playing the 3GP in Nokia 6600 mobile...

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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Problem in playing the 3GP in Nokia 6600 mobile...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT