mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-07 23:03:11 +08:00
Adding release method to Media object
This commit is contained in:
parent
43c72e684c
commit
2504db13d7
@ -192,3 +192,10 @@ Media.prototype.stopRecord = function() {
|
|||||||
PhoneGap.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
|
PhoneGap.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release the resources.
|
||||||
|
*/
|
||||||
|
Media.prototype.release = function() {
|
||||||
|
PhoneGap.exec(null, null, "Media", "release", [this.id]);
|
||||||
|
};
|
||||||
|
|
||||||
|
@ -77,13 +77,17 @@ public class AudioHandler extends Plugin {
|
|||||||
long l = this.getDurationAudio(args.getString(0), args.getString(1));
|
long l = this.getDurationAudio(args.getString(0), args.getString(1));
|
||||||
return new PluginResult(status, l);
|
return new PluginResult(status, l);
|
||||||
}
|
}
|
||||||
|
else if (action.equals("release")) {
|
||||||
|
boolean b = this.release(args.getString(0));
|
||||||
|
return new PluginResult(status, b);
|
||||||
|
}
|
||||||
return new PluginResult(status, result);
|
return new PluginResult(status, result);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies if action to be executed returns a value and should be run synchronously.
|
* Identifies if action to be executed returns a value and should be run synchronously.
|
||||||
*
|
*
|
||||||
@ -117,6 +121,20 @@ public class AudioHandler extends Plugin {
|
|||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// LOCAL METHODS
|
// LOCAL METHODS
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release the audio player instance to save memory.
|
||||||
|
*
|
||||||
|
* @param id The id of the audio player
|
||||||
|
*/
|
||||||
|
private boolean release(String id) {
|
||||||
|
if (!this.players.containsKey(id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AudioPlayer audio = this.players.get(id);
|
||||||
|
audio.destroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start recording and save the specified file.
|
* Start recording and save the specified file.
|
||||||
|
Loading…
Reference in New Issue
Block a user