package jbass; import anywheresoftware.b4a.BA; import anywheresoftware.b4a.keywords.DateTime; @BA.ShortName("MessageInformation") public class AudioFileInformation { private String filename; private long size; private double lengthseconds; private boolean valid; private boolean found; private boolean playing = false; private long startplayingtick = 0; private final long KB_threshold = 1024; private final long MB_threshold = 1024 * 1024; private final long GB_threshold = 1024 * 1024 * 1024; /** * Check if currently being played * @return true if playing */ public boolean getIsPlaying() { return playing; } /** * Set playing status * @param value : true if playing */ public void setIsPlaying(boolean value) { playing = value; if (playing) { startplayingtick = DateTime.getNow(); } else { startplayingtick = -1; } } /** * Get Playback duration since IsPlaying is set true * @return seconds of playback */ public int getPlaybackDuration() { if (startplayingtick==-1) { return -1; } else { return (int)((DateTime.getNow() - startplayingtick)/DateTime.TicksPerSecond); } } /** * Get Playback duration since IsPlaying is set true * @return duration of playback in String */ public String getPlaybackDurationInString() { int xx = getPlaybackDuration(); if (xx<0) { return "N/A"; } else if (xx<60) { return xx+" sec"; } else if (xx<3600) { int mm = xx / 60; int ss = xx - (mm*60); return mm+"min "+ss+"sec"; } else { int hh = xx / 3600; xx = xx - (hh*3600); int mm = xx / 60; int ss = xx - (mm*60); return hh+"h "+mm+"m "+ss+"s"; } } /** * Get File size in bytes * @return file size in bytes */ public long getSizeInBytes() { return size; } /** * Set File Size in bytes * @param value : file size in bytes */ public void setSizeInBytes(long value) { size = value; } /** * Get File Size in readable string * @return file size in readable string */ public String getSizeinString() { if (valid) { if (size