diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..1639645 --- /dev/null +++ b/build.xml @@ -0,0 +1,83 @@ + + + + + + Builds, tests, and runs the project . + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..35c039f --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Classpath to J2ME Ant extension library (libs.j2me_ant_ext.classpath property) is not set. For example: location of mobility/modules/org-netbeans-mobility-antext.jar file in the IDE installation directory. + Platform home (platform.home property) is not set. Value of this property should be ${platform.active.description} emulator home directory location. + Platform boot classpath (platform.bootclasspath property) is not set. Value of this property should be ${platform.active.description} emulator boot classpath containing all J2ME classes provided by emulator. + Must set src.dir + Must set build.dir + Must set dist.dir + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set preprocessed.dir + + + + + + + + + + + + + + + + + + Must set build.classes.dir + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must set obfuscated.classes.dir + + + + Must set obfuscated.classes.dir + Must set obfuscator.srcjar + Must set obfuscator.destjar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set preverify.classes.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MicroEdition-Configuration: ${platform.configuration} + + MicroEdition-Configuration: ${platform.configuration} + + + + MicroEdition-Profile: ${platform.profile} + + MicroEdition-Profile: ${platform.profile} + + + + Must set dist.jad + + + + + + + + + + + + + + + + + + + + + + + + ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.jad} + ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.manifest} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Starting emulator with port number ${active.debug.port} + + + + + + + + + + + + Starting emulator with port number ${active.debug.port} + + + + + + + + + + + + + + + + + Must set dist.javadoc.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${all.configurations} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property deployment.${deployment.method}.scriptfile not set. The property should point to an Ant script providing ${deployment.method} deployment. + + + + + + + + Classpath to Ant Contrib library (libs.ant-contrib.classpath property) is not set. + + + + + + + + + Active project configuration: @{cfg} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property build.root.dir is not set. By default its value should be \"build\". + Property dist.root.dir is not set. By default its value should be \"dist\". + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..a3de28a --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +build.xml.data.CRC32=b8ca046e +build.xml.script.CRC32=518797bb +build.xml.stylesheet.CRC32=03eab09b +nbproject/build-impl.xml.data.CRC32=b8ca046e +nbproject/build-impl.xml.script.CRC32=a371a0b9 +nbproject/build-impl.xml.stylesheet.CRC32=d670562e diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..4cfb46a --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,7 @@ +#Thu Jan 07 23:51:00 EET 2010 +netbeans.user=C\:\\Users\\aNNiMON\\.netbeans\\6.7 +javadoc.preview=true +deployment.counter=3 +config.active= +deployment.number=0.0.2 +app-version.autoincrement=true diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..ea068d7 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,141 @@ +abilities=MMAPI=1.1,SATSAJCRMI=1.0,SATSACRYPTO=1.0,JSR82=1.1,NOKIAUI=1.0,JSR226=1.0,MIDP=2.1,JSR229=1.1.0,SATSAAPDU=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0.1,J2MEWS=1.0,VSCL=2.1,WMA=2.0,JSR172=1.0,SEMC_EXT_JP8=1.0,ColorScreen,OBEX=1.0,NokiaUI=1.0,JSR238=1.0,JSR239=1.0,JSR211=1.0,JSR234=1.0,ScreenWidth=240,lib/semc_ext_jp8.jar=1.0,MascotV3=1.0,JSR75=1.0,JSR184=1.1,SATSAPKI=1.0,ScreenHeight=321,ScreenColorDepth=8,JSR180=1.0.1,J2MEXMLRPC=1.0, +all.configurations=\ +application.args= +application.description= +application.description.detail= +application.name= +application.vendor=Vendor +build.classes.dir=${build.dir}/compiled +build.classes.excludes=**/*.java,**/*.form,**/*.class,**/.nbintdb,**/*.mvd,**/*.wsclient,**/*.vmd +build.dir=build/${config.active} +build.root.dir=build +debug.level=debug +deployment.copy.target=deploy +deployment.instance=default +deployment.jarurl=${dist.jar} +deployment.method=NONE +deployment.override.jarurl=false +dist.dir=dist/${config.active} +dist.jad=SEPlayerService.jad +dist.jar=SEPlayerServiceLite.jar +dist.javadoc.dir=${dist.dir}/doc +dist.root.dir=dist +extra.classpath=${file.reference.MultimediaServices_API.jar} +file.reference.MultimediaServices_API.jar=../../NetBeans Libraries/MultimediaServices_API.jar +filter.exclude.tests=false +filter.excludes=newfile +filter.more.excludes=**/overview.html,**/package.html +filter.use.standard=true +jar.compress=true +javac.debug=true +javac.deprecation=false +javac.encoding=windows-1251 +javac.optimize=false +javac.source=1.3 +javac.target=1.3 +javadoc.author=false +javadoc.encoding= +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +libs.classpath=${file.reference.MultimediaServices_API.jar} +main.class= +main.class.class=applet +manifest.apipermissions= +manifest.file=manifest.mf +manifest.jad= +manifest.manifest= +manifest.midlets=MIDlet-1: SEPSLite,/icon.png,SEPS\n +manifest.others=MIDlet-Vendor: aNNiMON\nMIDlet-Name: SEPlayerServiceLite\nMIDlet-Version: 3.0\n +manifest.pushregistry= +name=SEPlayerService +no.dependencies=false +nokiaS80.application.icon= +nsicom.application.monitorhost= +nsicom.application.runremote= +nsicom.application.runverbose= +nsicom.remoteapp.location=\\My Documents\\NetBeans Applications +nsicom.remotevm.location=\\Windows\\creme\\bin\\CrEme.exe +obfuscated.classes.dir=${build.dir}/obfuscated +obfuscation.custom= +obfuscation.level=9 +obfuscator.destjar=${build.dir}/obfuscated.jar +obfuscator.srcjar=${build.dir}/before-obfuscation.jar +platform.active=Sony_Ericsson_SDK_2_5_0_4_for_the_Java_TM__ME_Platform_Emulator_ +platform.active.description=Sony Ericsson SDK 2.5.0.4 for the Java(TM) ME Platform(Emulator) +platform.apis=JSR234-1.0,SATSA-APDU-1.0,JSR211-1.0,JSR75-1.0,J2ME-WS-1.0,J2ME-XMLRPC-1.0,JSR82-1.1,SATSA-JCRMI-1.0,SATSA-CRYPTO-1.0,JSR239-1.0,JSR179-1.0.1,MascotV3-1.0,JSR184-1.1,JSR238-1.0,MMAPI-1.1,NokiaUI-1.0,JSR229-1.1.0,SATSA-PKI-1.0,JSR180-1.0.1,JSR226-1.0,JSR177-1.0,SEMC_EXT_JP8-1.0,VSCL-2.0,VSCL-2.1,WMA-2.0,lib/semc_ext_jp8.jar +platform.bootclasspath=${platform.home}/lib/mascotv3.jar:${platform.home}/lib/jsr226.jar:${platform.home}/lib/jsr256.jar:${platform.home}/lib/satsa-crypto.jar:${platform.home}/lib/jsr229.jar:${platform.home}/lib/jsr238.jar:${platform.home}/lib/j2me-xmlrpc.jar:${platform.home}/lib/jsr211.jar:${platform.home}/lib/vscl21.jar:${platform.home}/lib/satsa-jcrmi.jar:${platform.home}/lib/jsr082.jar:${platform.home}/lib/satsa-apdu.jar:${platform.home}/lib/jsr184.jar:${platform.home}/lib/nokiaext.jar:${platform.home}/lib/jsr239.jar:${platform.home}/lib/jsr75.jar:${platform.home}/lib/jsr179.jar:${platform.home}/lib/satsa-pki.jar:${platform.home}/lib/jsr180.jar:${platform.home}/lib/vscl.jar:${platform.home}/lib/mmapi.jar:${platform.home}/lib/j2me-ws.jar:${platform.home}/lib/wma20.jar:${platform.home}/lib/jsr234.jar:${platform.home}/lib/semc_ext_jp8.jar:${platform.home}/lib/cldcapi11.jar:${platform.home}/lib/midpapi20.jar +platform.configuration=CLDC-1.1 +platform.device=SonyEricsson_JP8_240x320_Emu +platform.fat.jar=true +platform.profile=MIDP-2.0 +platform.trigger=CLDC +platform.type=UEI-1.0.1 +preprocessed.dir=${build.dir}/preprocessed +preverify.classes.dir=${build.dir}/preverified +preverify.sources.dir=${build.dir}/preverifysrc +resources.dir=resources +ricoh.application.email= +ricoh.application.fax= +ricoh.application.icon= +ricoh.application.target-jar= +ricoh.application.telephone= +ricoh.application.uid=00489600 +ricoh.application.version= +ricoh.dalp.application-desc.auto-run=false +ricoh.dalp.application-desc.energy-save= +ricoh.dalp.application-desc.exec-auth= +ricoh.dalp.application-desc.visible=true +ricoh.dalp.argument= +ricoh.dalp.codebase= +ricoh.dalp.display-mode.color=true +ricoh.dalp.display-mode.is-4line-support=false +ricoh.dalp.display-mode.is-hvga-support=true +ricoh.dalp.display-mode.is-vga-support=false +ricoh.dalp.display-mode.is-wvga-support=false +ricoh.dalp.information.abbreviation= +ricoh.dalp.information.icon.basepath= +ricoh.dalp.information.icon.location= +ricoh.dalp.information.is-icon-used=true +ricoh.dalp.install.destination=hdd +ricoh.dalp.install.mode.auto=true +ricoh.dalp.install.work-dir=hdd +ricoh.dalp.is-managed=true +ricoh.dalp.resources.dsdk.version=2.0 +ricoh.dalp.resources.jar.basepath= +ricoh.dalp.resources.jar.version= +ricoh.dalp.version= +ricoh.icon.invert=false +ricoh.platform.target.version= +run.cmd.options= +run.jvmargs= +run.method=STANDARD +run.security.domain=trusted +run.use.security.domain=false +savaje.application.icon= +savaje.application.icon.focused= +savaje.application.icon.small= +savaje.application.uid=TBD +savaje.bundle.base= +savaje.bundle.debug=false +savaje.bundle.debug.port= +semc.application.caps= +semc.application.icon= +semc.application.icon.count= +semc.application.icon.splash= +semc.application.icon.splash.installonly=false +semc.application.uid=E0892899 +semc.certificate.path= +semc.private.key.password= +semc.private.key.path= +sign.alias= +sign.enabled=false +sign.keystore= +src.dir=src +use.emptyapis=true +use.preprocessor=true diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..77e54fd --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,10 @@ + + + org.netbeans.modules.kjava.j2meproject + + + SEPlayerService_Lite + 1.6 + + + diff --git a/src/Canv.java b/src/Canv.java index 1507ee9..8c5b0dd 100644 --- a/src/Canv.java +++ b/src/Canv.java @@ -1,11 +1,8 @@ +import com.nokia.mid.ui.DeviceControl; import com.sonyericsson.multimedia.*; import com.sonyericsson.multimedia.control.*; -import java.io.IOException; -import java.util.Calendar; -import javax.microedition.io.Connector; import javax.microedition.lcdui.*; -import javax.microedition.sensor.*; /* * To change this template, choose Tools | Templates @@ -18,10 +15,15 @@ import javax.microedition.sensor.*; */ public class Canv extends Canvas implements Runnable, MediaControlListener { + //public static int softUp1 = 0xFF242424, softUp2 = 0x87282828, softDn1 = 0x87151515, softDn2 = 0xFF181818, background = 0x00, + // line = 0x00BB00, text = 0x009900, valuet = 0x0000E6, inf = 0x992235; + public static int softUp1, softUp2, softDn1, softDn2, background, line, text, valuet, inf; + private int w,h; - private boolean lite, shift, axcel, vis; + private boolean lite, vis; private int mode; - private int accelPrevDelta = 0; + + private Lyrics lrc; private Image I, album; private Engine2 e2; @@ -34,23 +36,17 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { private MediaControl mediaControl = null; private Media media = null; - private int[] channels = new int[3]; - private String[] channelNames = new String[3]; - private SensorConnection sensor; - private String URL; - public Canv() { setFullScreenMode(true); thr = new Thread(this); thr.start(); - shift = lite = false; - vis = axcel = true; + lite = false; + vis = true; mode = 0; //Режим плейера w = getWidth(); h = getHeight(); I = Image.createImage(w, h); G = I.getGraphics(); - getInfo(); service = MultimediaServiceManager.getMultimediaService("MediaPlayer"); mediaControl = (MediaControl)service.getControl("MediaControl"); mediaControl.addMediaControlListener(this); @@ -59,17 +55,47 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { protected void paint(Graphics g) { if(mode==0) drawPlayerCanvas(G); + else if(mode==1) drawVisual(G); g.drawImage(I, 0, 0, 20); } + private void drawVisual(Graphics g) { + g.setColor(background); + g.fillRect(0, 0, w, h); + g.setFont(medFont); + if (media != null) { + MetaData metaData = media.getMetaData(); + if (metaData != null) { + Object data = metaData.getValue(MetaData.TITLE_KEY); + if (data != null) drawTitle(g, (String) data); + + if (album != null) { + int ih = h-2*medFont.getHeight()-6; + if(album.getHeight()>ih) album = Effects.Resize(album, ih*album.getWidth()/album.getHeight(), ih); + g.drawImage(album, w/2, h/2, 3); + }else if(vis){ + if(e2==null) { + int ih = h-(2*medFont.getHeight())-6; + e2 = new Engine2(w-6, ih); + e2.setRun(true); + } + g.drawImage(e2.MainCanvas(), w/2, h/2, 3); + } + if(Rms.isLyric && lrc!=null) { + drawCenter(g, lrc.get5Lines(media.getMediaTime())); + } + } + } + drawSoft(g, "Меню", "Выход"); + } + private void drawPlayerCanvas(Graphics g) { - g.setColor(0); + g.setColor(background); g.fillRect(0, 0, w, h); drawTitle(g, "SEPS by aNNiMON"); int fh = smallFont_b.getHeight()+2; int py = fh+fh/2; g.setFont(medFont); - g.setColor(0x227A6F); if (media != null) { MetaData metaData = media.getMetaData(); if (metaData != null) { @@ -81,9 +107,11 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { data = metaData.getValue(MetaData.ARTIST_KEY); if (data != null) py = drawText(g, "Исполнитель: ", (String) data, py); - - data = metaData.getValue("filename"); - if (data != null) py = drawText(g, "Файл: ", (String) data, py); + + if(Rms.isLyric && lrc!=null) py = drawText(g, "", lrc.getLine(media.getMediaTime()), py); + //else if(lrc==null) py = drawText(g, String.valueOf(media.getMediaTime()), "", py); + //data = metaData.getValue(metaData.FILE_URI_KEY); + //if (data != null) if (album != null) { int ih = h-fh-2-py-20; @@ -98,23 +126,23 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { g.drawImage(e2.MainCanvas(), w/2, py+15, 17); } - if(axcel) { - g.setColor(0x992235); - g.drawString("Accel", 2, py+15, 20); - } if(vis) { - g.setColor(0x992235); + g.setColor(inf); g.drawString("Visual", 2, py+15+(smallFont_b.getHeight()+2), 20); } + if(Rms.isLyric) { + g.setColor(inf); + g.drawString("Lyrics", 2, py+15+2*(smallFont_b.getHeight()+2), 20); + } float div = ((float)w - 10) / (float)media.getDuration(); - g.setColor(0x0000E6); + g.setColor(valuet); g.fillRect(5, py, (int)(media.getMediaTime() * div), 10); - g.setColor(0x009900); + g.setColor(text); g.drawRect(5, py, w-10, 10); } } - drawSoft(g, "Свернуть", "Выход"); + drawSoft(g, "Меню", "Выход"); } public void keyPressed(int key) { @@ -123,9 +151,11 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { pauseTrack(); SEPS.midlet.destroyApp(true); } - if(key==-6) SEPS.midlet.dsp.setCurrent(null); - if(key==KEY_POUND) axcel=!axcel; + if(key==-6) new Menu(); if(key==KEY_STAR) vis=!vis; + if(key==KEY_NUM0) Rms.isLyric=!Rms.isLyric; + if(key==KEY_NUM1) rewind(); + if(key==KEY_NUM3) fastForward(); switch(ga) { case LEFT: prevTrack(); @@ -134,8 +164,10 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { nextTrack(); break; case UP: + upMode(); break; case DOWN: + downMode(); break; case FIRE: try { @@ -152,54 +184,10 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { keyPressed(key); } - public int getDelta(int channel, int threshold) { - int delta = 0; - try { - Data[] data = sensor.getData(1, -1, false, false, false); - int drx = 0; - - for (int i = 0; i < data.length; i++) { - if (data[i].getChannelInfo().getName().equals(channelNames[channel])) { - drx = data[i].getIntValues()[0]; - } - } - - delta = channels[channel] - drx; - channels[channel] = drx; - - if (Math.abs(delta) < threshold) { - delta = 0; - } - } catch (Throwable t) { - } - - return delta; - } - public void run() { while (true) { try { - final int delta = getDelta(0, 800); - - if (delta != 0) { - if (accelPrevDelta != 0 && (delta * accelPrevDelta) < 0) { - accelPrevDelta = 0; - } else { - accelPrevDelta = delta; - - Runnable runnable = new Runnable() { - - public void run() { - if (delta > 0 && axcel) { - nextTrack(); - } else if (delta < 0 && axcel) { - prevTrack(); - } - } - }; - (new Thread(runnable)).start(); - } - } + if(Rms.light) DeviceControl.setLights(0, 100); if(!vis) Thread.sleep(100); if (service != null) { repaint(); @@ -210,21 +198,24 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { } } - private void getInfo() { - SensorInfo[] info = SensorManager.findSensors("acceleration", null); - for (int i = 0; i < info.length; i++) { - SensorInfo s = info[i]; - URL = s.getUrl(); - ChannelInfo[] ci = s.getChannelInfos(); - for (int r = 0; r < ci.length; r++) { - ChannelInfo c = ci[r]; - channelNames[r] = c.getName(); - } - } - try { - sensor = (SensorConnection) Connector.open(URL); - } catch (IOException ex) { - ex.printStackTrace(); + private void initLyric(Media med) { + if (med == null) {return;} + lrc = null; + String at = ""; + String fl = ""; + MetaData metaData = med.getMetaData(); + if (metaData != null) { + Object data = metaData.getValue(MetaData.ARTIST_KEY); + if (data != null) at=at +(String)(data) + " - "; + + data = metaData.getValue(MetaData.TITLE_KEY); + if (data != null) at+=(String) data; + + data = metaData.getValue(MetaData.FILE_URI_KEY); + if (data != null) {fl=(String) data;fl=fl.substring(fl.lastIndexOf('/')+1, fl.lastIndexOf('.'));} + + if(Lyrics.isExists(at)) lrc = new Lyrics(at); + else if(Lyrics.isExists(fl)) lrc = new Lyrics(fl); } } @@ -244,7 +235,7 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { } } - private void pauseTrack() { + public void pauseTrack() { try { mediaControl.pause(); } catch (ControlException ex) { @@ -260,32 +251,48 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { } } - public static String getTime(int mode) { - String dd, mm, yy, _h, m, s; - Calendar cal = Calendar.getInstance (); - dd = String.valueOf (cal.get (Calendar.DAY_OF_MONTH)); - if (dd.length () == 1) - dd = "0" + dd; - mm = String.valueOf (cal.get (Calendar.MONTH) + 1); - if (mm.length () == 1) - mm = "0" + mm; - yy = String.valueOf (cal.get (Calendar.YEAR)); - _h = String.valueOf (cal.get (Calendar.HOUR_OF_DAY)); - if (_h.length () == 1) - _h = "0" + _h; - m = String.valueOf (cal.get (Calendar.MINUTE)); - if (m.length () == 1) - m = "0" + m; - s = String.valueOf (cal.get (Calendar.SECOND)); - if (s.length () == 1) - s = "0" + s; - String time; - if(mode==1) time = _h+":"+m+":"+s; - else if(mode==2) time = (dd+"."+mm+"."+yy.substring(2)); - else time = (dd+"."+mm+"."+yy.substring(2)+" "+_h+":"+m+":"+s); - return time; + private void fastForward() { + try { + mediaControl.skip(10); + } catch (ControlException ex) { + ex.printStackTrace(); + } } + private void rewind() { + try { + mediaControl.skip(-10); + } catch (ControlException ex) { + ex.printStackTrace(); + } + } + +// public static String getTime(int mode) { +// String dd, mm, yy, _h, m, s; +// Calendar cal = Calendar.getInstance (); +// dd = String.valueOf (cal.get (Calendar.DAY_OF_MONTH)); +// if (dd.length () == 1) +// dd = "0" + dd; +// mm = String.valueOf (cal.get (Calendar.MONTH) + 1); +// if (mm.length () == 1) +// mm = "0" + mm; +// yy = String.valueOf (cal.get (Calendar.YEAR)); +// _h = String.valueOf (cal.get (Calendar.HOUR_OF_DAY)); +// if (_h.length () == 1) +// _h = "0" + _h; +// m = String.valueOf (cal.get (Calendar.MINUTE)); +// if (m.length () == 1) +// m = "0" + m; +// s = String.valueOf (cal.get (Calendar.SECOND)); +// if (s.length () == 1) +// s = "0" + s; +// String time; +// if(mode==1) time = _h+":"+m+":"+s; +// else if(mode==2) time = (dd+"."+mm+"."+yy.substring(2)); +// else time = (dd+"."+mm+"."+yy.substring(2)+" "+_h+":"+m+":"+s); +// return time; +// } + public void mediaControlUpdate(int eventId, ControlEvent event) { try { switch (eventId) { @@ -314,6 +321,7 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { album = null; } } + if(Rms.isLyric) initLyric(this.media); } catch (Throwable t) { t.printStackTrace(); } @@ -322,11 +330,12 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { private void drawTitle(Graphics g, String text) { int fh = medFont.getHeight()+4; - g.setColor(0x0000E6); + g.setColor(valuet); g.setFont(medFont); + if(Rms.skinid==3) {text=toEmo(text);} g.drawString(text, w/2, 2, 17); - drawRect(g, 0xFF242424, 0x87282828, 0, 0, w, fh/2); - drawRect(g, 0x87151515, 0xFF181818, 0, fh/2, w, fh/2); + drawRect(g, softUp1, softUp2, 0, 0, w, fh/2); + drawRect(g, softDn1, softDn2, 0, fh/2, w, fh/2); } public void drawRect(Graphics g, int color1, int color2, int x1, int y1, int w, int h) { @@ -370,24 +379,50 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { private void drawSoft(Graphics g, String lsoft, String rsoft) { int fh = medFont.getHeight()+2; - g.setColor(0x009900); + g.setColor(text); g.setFont(medFont); g.drawString(lsoft, 2, h-2, 36); g.drawString(rsoft, w-2, h-2, 40); - drawRect(g, 0xFF242424, 0x87282828, 0, h-fh, w, fh/2); - drawRect(g, 0x87151515, 0xFF181818, 0, h-fh/2, w, fh/2); + drawRect(g, softUp1, softUp2, 0, h-fh, w, fh/2); + drawRect(g, softDn1, softDn2, 0, h-fh/2, w, fh/2); + } + + private void drawCenter(Graphics g, String[] lines) { + if(lines==null) return; + Font sm = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); + int fh = sm.getHeight()+2; + g.setFont(sm); + String v; + drawRect(g, ((160<<24)| Canv.background),((160<<24)| Canv.background), 0, h/2-fh*2, w, fh*5); + for(int i=0; itw) { g.translate(tw-10, g.getTranslateY()); g.drawString(value, 2, y, 20); @@ -396,4 +431,31 @@ public class Canv extends Canvas implements Runnable, MediaControlListener { return y+(smallFont_b.getHeight()+2); } + + private String toEmo(String s) { + StringBuffer sb = new StringBuffer(); + int i = 0; + boolean up = true; + while(i= 0xc0 && ch <= 0xFF) ? (ch + 0x350) : ch)); + } + dis.close(); + } catch (Exception e) {e.printStackTrace();} + return strBuff.toString(); + } +} diff --git a/src/Lyrics.java b/src/Lyrics.java new file mode 100644 index 0000000..a7395f3 --- /dev/null +++ b/src/Lyrics.java @@ -0,0 +1,233 @@ + +import java.io.*; +import java.util.Vector; +import javax.microedition.io.*; +import javax.microedition.io.file.FileConnection; + +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author aNNiMON + */ +public class Lyrics { + + private String[] lrc; + private int[] time; + + /** + * Конструктор класса + * @param lyricsname - имя [Исполнитель] - [Заголовок] + * или [name] + */ + public Lyrics(String lyricsname) { + String all = openLirics(lyricsname); + lrc = threshold(all, false); + String[] tm = threshold(all, true); + all = null; + time = getIntTime(tm); + tm = null; + System.gc(); + } + + public String getLine(int t) { + for(int i=0; i=2 && idx= 0xc0 && ch <= 0xFF) ? (ch + 0x350) : ch)); + } + is.close(); + fc.close(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return sb.toString(); + } + + /** + * Разбиение текста на строки + * @param text - весь текст + * @param time - получать время(true) или текст песни(false) + * @return + */ + private String[] threshold(String text, boolean time) + { + Vector v = new Vector(); + char c = '\n'; + int j = text.length(); + String s2 = ""; + for(int k = 0; k < j; k++) + { + int i = text.charAt(k); + if(i == c) + { + if(s2.length() > 0) + { + if(time && isNumChar(s2.charAt(1))) v.addElement(s2.substring(0, s2.indexOf(']')+1).trim()); + else if(isNumChar(s2.charAt(1))) v.addElement(s2.substring(s2.lastIndexOf(']')+1).trim()); + s2 = ""; + } + } else + { + s2 = s2 + String.valueOf((char)i); + } + } + if(s2.length() > 0) { + if(time && isNumChar(s2.charAt(1))) v.addElement(s2.substring(0, s2.indexOf(']')+1).trim()); + else if(isNumChar(s2.charAt(1))) v.addElement(s2.substring(s2.lastIndexOf(']')+1).trim()); + } + String[] m; + m = new String[v.size()]; + v.copyInto(m); + return m; + } + + /** + * Проверка на символ, содержащий число. + * @param ch - символ + * @return + */ + private boolean isNumChar(char ch) { + return ch >= '0' && ch <= '9'; + } + + /** + * Преобразовывает строку вида [00:00.00] в число + * @param tm + * @return + */ + private int[] getIntTime(String[] tm) { + int[] out = new int[tm.length]; + for(int i=0; i '\177' && ch < '\u0800') { + sb.append('%'); + sb.append(Integer.toHexString((ch >> 6 | 0xc0) + 256).substring(1)); + sb.append('%'); + sb.append(Integer.toHexString((ch & 0x3f | 0x80) + 256).substring(1)); + break; + } + if (ch > '\u07FF' && ch < '\0') { + sb.append('%'); + sb.append(Integer.toHexString((ch >> 12 | 0xe0) + 256).substring(1)); + sb.append('%'); + sb.append(Integer.toHexString((ch >> 6 & 0x3f | 0x80) + 256).substring(1)); + sb.append('%'); + sb.append(Integer.toHexString((ch & 0x3f | 0x80) + 256).substring(1)); + } + break; + case 0: //'\0' + case 32: sb.append("%20"); break;// ' ' + case 61: sb.append("%3d"); break;// '=' + case 43: sb.append("%2b"); break;// '+' + case 39: sb.append("%27"); break;// '\'' + case 46: sb.append("%2E"); break;// '.' + case 60: sb.append("%3c"); break;// '<' + case 62: sb.append("%3e"); break;// '>' + case 35: sb.append("%23"); break;// '#' + case 37: sb.append("%25"); break;// '%' + case 38: sb.append("%26"); break;// '&' + case 123:sb.append("%7b"); break;// '{' + case 125:sb.append("%7d"); break;// '}' + case 92: sb.append("%5c"); break;// '\\' + case 94: sb.append("%5e"); break;// '^' + case 126:sb.append("%73"); break;// '~' + case 91: sb.append("%5b"); break;// '[' + case 93: sb.append("%5d"); break;// ']' + case 58: sb.append("%3A"); break;// ':' + case 47: sb.append("%2F"); break;// '/' + case 63: sb.append("%3F"); break;// '?' + case 45: sb.append("%2D"); break;// '-' + case 33: sb.append("%21"); break;// '!' + case 59: sb.append("%3B"); break;// ';' + } + } + return sb.toString(); + } +} diff --git a/src/Menu.java b/src/Menu.java new file mode 100644 index 0000000..b3be7f6 --- /dev/null +++ b/src/Menu.java @@ -0,0 +1,38 @@ +import javax.microedition.lcdui.*; + +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author aNNiMON + */ +public class Menu implements CommandListener { + + private List ls; + private Display dsp; + + public Menu() { + String[] m = new String[] {"Вернуться", "Настройки", "О программе", "Свернуть", "Выход"}; + ls = new List("Меню", List.IMPLICIT, m, null); + ls.setCommandListener(this); + dsp = SEPS.midlet.dsp; + dsp.setCurrent(ls); + } + + public void commandAction(Command c, Displayable d) { + if(c.equals(List.SELECT_COMMAND)) { + int i = ls.getSelectedIndex(); + switch(i) { + case 0: dsp.setCurrent(SEPS.midlet.cnv); break; + case 1: dsp.setCurrent(new Options()); break; + case 2: dsp.setCurrent(new Info()); break; + case 3: dsp.setCurrent(null); break; + case 4: SEPS.midlet.destroyApp(true); break; + } + } + } + +} diff --git a/src/Options.java b/src/Options.java new file mode 100644 index 0000000..277b58b --- /dev/null +++ b/src/Options.java @@ -0,0 +1,90 @@ +import javax.microedition.lcdui.*; + +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author aNNiMON + */ +public class Options extends Form implements CommandListener { + + private Command back,ok; + private TextField az, un, cc, hp; + private ChoiceGroup skin, cRC; + + + public Options() { + super("Настройки"); + back = new Command("Назад", Command.BACK, 3); + ok = new Command("Ok", Command.OK, 1); + az = new TextField("Папка с текстами:", Rms.lrcpath, 256, TextField.ANY); +// un = new TextField(L.str[L.noc]+":", String.valueOf(P.undo), 2, TextField.NUMERIC); +// cc = new TextField(L.str[L.cch]+":", "000000", 6, TextField.ANY); +// hp = new TextField(L.str[L.ach], String.valueOf(P.heap), 2, TextField.ANY); + skin = new ChoiceGroup ("Скины", ChoiceGroup.EXCLUSIVE); + cRC = new ChoiceGroup ("", ChoiceGroup.MULTIPLE); + appendOther(); + StrokeStyle(); + } + + public void commandAction(Command c, Displayable d) { + if (c==back) {new Menu();} + + if ((c==ok || c==List.SELECT_COMMAND)) { + new Skin(Rms.skinid = skin.getSelectedIndex()); + Rms.lrcpath=az.getString(); +// P.az=Integer.parseInt(az.getString()); +// P.curcolor = getHexValue(cc.getString()); +// P.heap = Integer.parseInt(hp.getString()); + Rms.light = cRC.isSelected(0); +// P.dsI = cRC.isSelected(1); +// P.isUndo = cRC.isSelected(2); +// P.isEfView = cRC.isSelected(3); +// P.isLight = cRC.isSelected(4); +// P.BOC = cRC.isSelected(5); +// P.undo=Integer.parseInt(un.getString()); +// Editor.isteps = new Image[P.undo]; +// Editor.ist=0; + new Menu(); + } + } + + private void StrokeStyle() { + append(skin); + append(az); +// append(cc); +// append(hp); + append(cRC); +// append(un); + addCommand(ok); + addCommand(back); + setCommandListener(this); + SEPS.midlet.dsp.setCurrent(this); + } + + private void appendOther() { + skin.append("Стандартный SEPS", null); + skin.append("ProPaintMobile", null); + skin.append("Готический", null); + skin.append("Эмо", null); + skin.append("SEclub.ORG", null); + skin.append("aNNiMON Forum", null); + skin.setSelectedIndex(Rms.skinid, true); + + cRC.append("Постоянная подсветка", null); +// cRC.append(L.str[L.stias], null); +// cRC.append(L.str[L.aplca], null); +// cRC.append(L.str[L.prwef], null); +// cRC.append(L.str[120], null); +// cRC.append(L.str[123], null); + cRC.setSelectedIndex(0, Rms.light); +// cRC.setSelectedIndex(1, P.dsI); +// cRC.setSelectedIndex(2, P.isUndo); +// cRC.setSelectedIndex(3, P.isEfView); +// cRC.setSelectedIndex(4, P.isLight); +// cRC.setSelectedIndex(5, P.BOC); + } +} diff --git a/src/Rms.java b/src/Rms.java new file mode 100644 index 0000000..7fa307c --- /dev/null +++ b/src/Rms.java @@ -0,0 +1,76 @@ + +import java.io.*; +import javax.microedition.rms.*; + +/** + * + * @author aNNiMON + */ +public class Rms { + + private static final String rmsName = "SEPSLite"; + private static RecordStore rmsStore; + public static boolean firstStart = true; // первый старт + public static int skinid = 0; + public static boolean isLyric = true; + public static String lrcpath = "c:/music/Lyrics/"; + public static boolean light = false; + /** + * Сохранение настроек + */ + public static void saveOptions() { + if (rmsStore != null) { + byte[] options = null; + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + dos.writeBoolean(firstStart); + dos.writeInt(skinid); + dos.writeBoolean(isLyric); + dos.writeUTF(lrcpath); + dos.writeBoolean(light); + dos.flush(); + options = baos.toByteArray(); + dos.close(); + rmsStore.setRecord(1, options, 0, options.length); + } catch (InvalidRecordIDException ridex) { + try { + rmsStore.addRecord(options, 0, options.length); + } catch (RecordStoreException ex) { + } + } catch (Exception ex) { + } + } + if (rmsStore != null) { + try { + rmsStore.closeRecordStore(); + rmsStore = null; + } catch (RecordStoreException ex) { + } + } + } + + /** + * Восстановить настройки + */ + public static void restoreOptions() { + try { + rmsStore = RecordStore.openRecordStore(rmsName, true); + } catch (RecordStoreException ex) { + rmsStore = null; + } + if (rmsStore != null) { + try { + DataInputStream dis = new DataInputStream(new ByteArrayInputStream(rmsStore.getRecord(1))); + firstStart = dis.readBoolean(); + skinid = dis.readInt(); + isLyric = dis.readBoolean(); + lrcpath = dis.readUTF(); + light = dis.readBoolean(); + dis.close(); + } catch (Exception ex) { + } + } + } +} + diff --git a/src/SEPS.java b/src/SEPS.java index bb0eee5..1407cc6 100644 --- a/src/SEPS.java +++ b/src/SEPS.java @@ -13,20 +13,27 @@ public class SEPS extends MIDlet { public static SEPS midlet; public Display dsp; + public Canv cnv; public SEPS() { midlet = this; + Rms.restoreOptions(); + new Skin(Rms.skinid); + cnv = new Canv(); dsp = Display.getDisplay(this); } public void startApp() { - dsp.setCurrent(new Canv()); + dsp.setCurrent(cnv); } public void pauseApp() { } public void destroyApp(boolean unco) { + if(Rms.firstStart) Rms.firstStart=false; + Rms.saveOptions(); + cnv.pauseTrack(); notifyDestroyed(); } } diff --git a/src/Skin.java b/src/Skin.java new file mode 100644 index 0000000..bbebf1e --- /dev/null +++ b/src/Skin.java @@ -0,0 +1,106 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author aNNiMON + */ +public class Skin { + + public Skin(int skin) { + switch(skin) { + case 0: //default + setSEPS(); + break; + case 1: //PPM + setPPM(); + break; + case 2: //Gothic + setGothic(); + break; + case 3: //Emo + setEmo(); + break; + case 4: //SEclub + setSEclub(); + break; + case 5: //SEclub + setaNM(); + break; + } + } + + private void setSEPS() { + Canv.softUp1 = 0xFF242424; + Canv.softUp2 = 0x87282828; + Canv.softDn1 = 0x87151515; + Canv.softDn2 = 0xFF181818; + Canv.background = 0x00; + Canv.line = 0x00BB00; + Canv.text = 0x009900; + Canv.valuet = 0x0000E6; + Canv.inf = 0x992235; + } + + private void setPPM() { + Canv.softUp1 = 0xFF3477d5; + Canv.softUp2 = 0x883477d5; + Canv.softDn1 = 0x8812396f; + Canv.softDn2 = 0xFF12396f; + Canv.background = 0xFFFFFF; + Canv.line = 0x0064A8; + Canv.text = 0x282828; + Canv.valuet = 0x296321; + Canv.inf = 0xA2DBF9; + } + + private void setGothic() { + Canv.softUp1 = 0xFF141414; + Canv.softUp2 = 0x87181818; + Canv.softDn1 = 0x87151515; + Canv.softDn2 = 0xFF181818; + Canv.background = 0x00; + Canv.line = 0x6D6D6D; + Canv.text = 0x595959; + Canv.valuet = 0x666666; + Canv.inf = 0x474747; + } + + private void setEmo() { + Canv.softUp1 = 0xFF1E1012; + Canv.softUp2 = 0x8887466D; + Canv.softDn1 = 0x88512C31; + Canv.softDn2 = 0xFFCE6BA6; + Canv.background = 0xFF879B; + Canv.line = 0xFF28A9; + Canv.text = 0x00; + Canv.valuet = 0x60204A; + Canv.inf = 0xD17DDB; + } + + private void setSEclub() { + Canv.softUp1 = 0xFF295723; + Canv.softUp2 = 0x88295723; + Canv.softDn1 = 0x8834EB5E; + Canv.softDn2 = 0xFF34EB5E; + Canv.background = 0x295723; + Canv.line = 0xDFFFFF; + Canv.text = 0x2ED45E; + Canv.valuet = 0x34EB5E; + Canv.inf = 0xCAC410; + } + + private void setaNM() { + Canv.softUp1 = 0xFF99AACC; + Canv.softUp2 = 0x7599AACC; + Canv.softDn1 = 0x75CCFF99; + Canv.softDn2 = 0xFFCCFF99; + Canv.background = 0xFFFF99; + Canv.line = 0x002B55; + Canv.text = 0x333399; + Canv.valuet = 0x640022; + Canv.inf = 0x008000; + } +} diff --git a/src/about b/src/about new file mode 100644 index 0000000..219fa33 --- /dev/null +++ b/src/about @@ -0,0 +1,45 @@ +Sony Ericsson Player Service 3.0 + +Автор: Виктор aNNiMON Мельник +Сайт разработчика: http://annimon.wen.ru/ + +Программа - управление родным плейером для телефонов Sony Ericsson с поддержкой MultimediaService API и датчиком движения. + +Управление: + Влево/Вправо/Движение акселерометром - Переключение песен. + Вверх/Вниз - переключение режимов: Всё/Визуализация/Текст. + 1/3 - Перемотка назад/вперед. + 5/Огонь - Пауза. + 0 - Включение/Отключение текстов песен. + * - Включение/Отключение визуализации. + # - Включение/Отключение акселерометра. + +Изменения: + Версия 3.0 + - Исправлен показ обложки в полноэкранном режиме. + - Добавил поддержку текстов песен (lrc). Файлы кидаем в папку Lyrics. Например c:/music/Lyrics/Bullet For My Valentine - Hand of Blood.lrc + - Сделал настройку пути к папке хранения .lrc текстов. + - Добавил постоянную подсветку и её настройку. + - Добавил 2 новых скина. + + Версия 2.0 + - Добавлена настройка чувствительности акселерометра, + - Добавлены скины: ProPaintMobile, Готический, Эмо(в котором все английские буквы ПрЫгАюТ), + - Режим визуализации. Переключается клавишами Вверх/Вниз, + - Добавил перемотку клавишами 1 и 3. + +Поддержка lrc: + Lyrics-файл (.lrc) должен быть записан в кодировке WIN-1251, иначе возможны ошибки при чтении. + Имя lrc-файла должно быть либо "[Название группы] - [Название песни].lrc", либо "[Название исходного фудиофайла].ltc". + Примеры: "Three Days Grace - Someone Who Cares.lrc", "08 - Someone Who Cares.lrc", "Аудиодорожка_8_3373656326.lrc" + +-= Помощь автору =- +Web-Money: +E254903540273 +R347617663674 +U299970747663 +Z393537409230 + +- - - - - - - - - - - - - - - - - - +© aNNiMON (Melnik Software) +Украина, 2010 \ No newline at end of file diff --git a/src/newfile b/src/newfile new file mode 100644 index 0000000..20b41e8 --- /dev/null +++ b/src/newfile @@ -0,0 +1 @@ +aNNiMON, Ну Вот юин эсприта, основной плагмэйкер... 2542902 Вот LocID \ No newline at end of file