Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/screenshots
/example
Binary file removed android/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ public class OGUIWaveView extends View {

public OGUIWaveView(Context context) {
super(context);

}




public void updatePlayHead(float currentSeek){
mCurrentSeek = currentSeek;

invalidate();
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Expand All @@ -49,7 +45,5 @@ protected void onDraw(Canvas canvas) {
paint.setStrokeWidth(8);
paint.setAntiAlias(true);
canvas.drawLine(currrentXPos, 0, currrentXPos, canvas.getHeight(), paint);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.support.annotation.Nullable;
import android.util.Log;


import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener;
Expand All @@ -17,7 +16,6 @@
import com.facebook.react.uimanager.annotations.ReactProp;
import com.ringdroid.WaveformView;


import static com.facebook.react.common.ReactConstants.TAG;

/**
Expand All @@ -26,33 +24,25 @@

public class OGWaveManager extends SimpleViewManager<OGWaveView> implements LifecycleEventListener,WaveformView.WaveformListener {




private Callback onPressCallback;
public static final String REACT_CLASS = "OGWave";
private ReactContext mcontext;
//private WaveformView mWaveView;

@Override
public String getName() {

return REACT_CLASS;
}



@Override
public OGWaveView createViewInstance(ThemedReactContext context) {
context.addLifecycleEventListener(this);
mcontext = context;

// deleteFiles(Environment.getExternalStorageDirectory().toString(),"mp3");
OGWaveView mWaveView = new OGWaveView(context);

mWaveView.setWaveformListener(this);


return mWaveView;
}

Expand All @@ -64,7 +54,6 @@ public void setTestId(OGWaveView view, String testId) {

@ReactMethod
public void testCallback(Callback cb) {

Log.e("XSXGOT","TESXT CA:LBACK CALLED!!! ");
String sampleText = "Java is fun";
int textLength = sampleText.length();
Expand All @@ -84,47 +73,39 @@ public void setSrc(OGWaveView view, @Nullable ReadableMap src) {
public void setComponentID(OGWaveView view, String componentID) {
Log.e("XSXGOT","componentID SETTED:::!!!!" +componentID);
view.setComponentID(componentID);

}



@ReactProp(name = "autoPlay", defaultBoolean = false)
public void setAutoPlay(OGWaveView view, boolean autoPlay) {
Log.e("XSXSXS","setAutoPlay:::: "+autoPlay);
view.setAutoPlay(autoPlay);
}


@ReactProp(name = "waveFormStyle")
public void setWaveFormStyle(OGWaveView view, @Nullable ReadableMap waveFormStyle) {


view.setmWaveColor(waveFormStyle.getInt("ogWaveColor"));
view.setScrubColor(waveFormStyle.getInt("ogScrubColor"));
}
@ReactProp(name = "play")
public void setPlay(OGWaveView view, @Nullable boolean play) {

view.onPlay(play);

view.onPlay(play);
}


@ReactProp(name = "stop")
public void setStop(OGWaveView view, @Nullable boolean stop){
view.onStop(stop);
}

/** @ReactProp(name = "pause")
public void setPause(OGWaveView view, @Nullable Callback pause){
// view.onPlay();

}

@ReactProp(name = "stop")
public void setStop(OGWaveView view, @Nullable Callback stop){
//view.onPlay();

}**/


@Override
public void onHostResume() {

Expand All @@ -148,22 +129,18 @@ private void sendEvent(ReactContext reactContext,

@Override
public void waveformTouchStart(ReactContext context, String componentID) {

WritableMap map = Arguments.createMap();
map.putString("componentID",componentID);
sendEvent(context, "OGOnPress",map);
Log.e("OGTAGDEBUG::", "waveformTouchStart: " );

}

@Override
public void waveformFinishPlay(ReactContext context, String componentID) {

WritableMap map = Arguments.createMap();
map.putString("componentID",componentID);
sendEvent(context, "OGFinishPlay",map);
Log.e("OGTAGDEBUG::", "waveformFinishPlay: " );

}

@Override
Expand Down Expand Up @@ -201,4 +178,3 @@ public void waveformZoomOut() {

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public class OGWavePackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();



return modules;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

public class OGWaveView extends FrameLayout {


private final OGUIWaveView mUIWave;
private MediaPlayer mMediaPlayer;
private WaveformView mWaveView;
Expand All @@ -37,52 +36,45 @@ public class OGWaveView extends FrameLayout {
private boolean mAutoplay = false;
private boolean isCreated = false;




public OGWaveView(ReactContext context) {
super(context);
mContext = context;

mWaveView = new WaveformView(mContext, this);
mUIWave = new OGUIWaveView(mContext);


mUIWave.setBackgroundColor(Color.TRANSPARENT);


}
public void setmWaveColor(int mWaveColor) {

public void setmWaveColor(int mWaveColor) {
this.mWaveView.setmWaveColor(mWaveColor);


}

public void setScrubColor(int scrubcolor){
mScrubColor = scrubcolor;
mUIWave.scrubColor=this.mScrubColor;
mUIWave.invalidate();
}

public void onPlay(boolean play){
if(play){
if (play) {
this.mMediaPlayer.start();


}else{
if(mMediaPlayer != null && mMediaPlayer.isPlaying())
} else {
if (mMediaPlayer != null && mMediaPlayer.isPlaying())
mMediaPlayer.pause();

}

progressReportinghandler.postDelayed(progressRunnable, 500);

}

public void onPause(){
this.mMediaPlayer.pause();
}
public void onStop(){
this.mMediaPlayer.stop();

public void onStop(boolean stop) {
if (stop) {
this.mMediaPlayer.stop();
}
}

public void setAutoPlay(boolean autoplay){
Expand All @@ -94,7 +86,6 @@ public void setAutoPlay(boolean autoplay){
}

progressReportinghandler.postDelayed(progressRunnable, 500);

}

public void createMediaPlayer() {
Expand All @@ -104,7 +95,6 @@ public void createMediaPlayer() {
addView(this.mUIWave);

this.mWaveView.setOnTouchListener(new OnTouchListener(){

@Override
public boolean onTouch(View v, MotionEvent event) {

Expand All @@ -115,17 +105,13 @@ public boolean onTouch(View v, MotionEvent event) {

return true;
}

});


this.mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

@Override
public void onCompletion(MediaPlayer mp) {
waveformListener.waveformFinishPlay(mContext, componentID);
}

});
}

Expand Down Expand Up @@ -162,8 +148,6 @@ public void setSoundFile(SoundFile soundFile) {

private WaveformView.WaveformListener waveformListener;



public WaveformView.WaveformListener getWaveformListener() {
return waveformListener;
}
Expand All @@ -174,12 +158,10 @@ public void setWaveformListener(WaveformView.WaveformListener waveformListener)

private Handler progressReportinghandler = new Handler();
private Runnable progressRunnable = new Runnable() {

public void run() {
try {
if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
new UpdateProgressRequest().execute();

// seconds
progressReportinghandler.postDelayed(progressRunnable, 100);
}
Expand All @@ -197,18 +179,13 @@ public void setComponentID(String componentID) {
this.componentID = componentID;
}


protected class UpdateProgressRequest extends AsyncTask<Void, Void, Float> {

@Override
protected Float doInBackground(Void... params) {

if (mMediaPlayer.isPlaying()) {
String offset = Integer.valueOf(
mMediaPlayer.getCurrentPosition()).toString();



Float currrentPos = (float) mMediaPlayer.getCurrentPosition()/mMediaPlayer.getDuration();

return currrentPos;
Expand All @@ -219,12 +196,7 @@ protected Float doInBackground(Void... params) {
@Override
protected void onPostExecute(Float aFloat) {
super.onPostExecute(aFloat);


mUIWave.updatePlayHead(aFloat);
}
}



}
Loading