Open danigit001 opened 11 years ago
I just made a code change to the VideoPlayer which should make it backward compatible with the old window.plugins.videoPlayer way of doing things. If you are using the 2.2.0 version of the plugin go get the new JS file.
https://github.com/macdonst/VideoPlayer/blob/master/2.2.0/www/video.js
Ive realized after writting the issue. You said that this is the old way to call it. Which is the best way to do it? Thank you very much for your help.
Enviado de Samsung Mobilemacdonst notifications@github.com escribió:I just made a code change to the VideoPlayer which should make it backward compatible with the old window.plugins.videoPlayer way of doing things. If you are using the 2.2.0 version of the plugin go get the new JS file.
https://github.com/macdonst/VideoPlayer/blob/master/2.2.0/www/video.js
— Reply to this email directly or view it on GitHub.
The newer way of doing thing is to specify where you want the video player object stored yourself. It just doesn't default to window.plugins or at least it didn't until I checked in that backwards compatibility patch.
You would do something like:
var videoPlayer = cordova.require("cordova/plugins/videoplayer");
videoPlayer.play("blah");
hi macdonst,
im so embarrased to ask again for youre help, but im in the same situation with the emailcomposer plugin, im not able to use it from the html, is always undefined. Im finishing my first phonegap app, im using screenshot, video and emailcompser plugins. In the screenshot i found problems util ive realized that after the screeenshot i should make an gallery refresh, after that all worked fine, the video thanks for youre help is now working but with the email composer im stuck. i will be very gratefull if you can help me with this plugin in 2.2.
Thanks a lot
2013/1/21 macdonst notifications@github.com
The newer way of doing thing is to specify where you want the video player object stored yourself. It just doesn't default to window.plugins or at least it didn't until I checked in that backwards compatibility patch.
You would do something like:
var videoPlayer = cordova.require("cordova/plugins/videoplayer"); videoPlayer.play("blah");
— Reply to this email directly or view it on GitHubhttps://github.com/macdonst/VideoPlayer/issues/8#issuecomment-12484137.
No matter I try on cordova 2.3.0 I cant get it works. I get the same error on this post, I will try every post before mine and I'll tell you.
There is some known issue about 2.3 ?
Thanks.
PD. I am using cordova /bin cli I tried with cordova and phongap versions
Got it solved. I can send you an example.
Enviado de Samsung Mobile"Alejandro Trujillo J." notifications@github.com escribió:No matter I try on cordova 2.3.0 I cant get it works. I get the same error on this post, I will try every post before mine and I'll tell you.
There is some known issue about 2.3 ?
Thanks.
— Reply to this email directly or view it on GitHub.
Solved with socialShare plugin, im using it to attach always the same file to the email, just get uri as an parameter in the startEmailActivity .
.java
import java.io.File; import java.util.ArrayList;
import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject;
import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Environment;
import org.apache.cordova.api.LOG; import org.apache.cordova.api.Plugin; import org.apache.cordova.api.PluginResult;
public class SocialShare extends Plugin {
private String callback;
public String smsCopy = "";
@Override
public PluginResult execute(String action, JSONArray args, String callbackId) {
try
{
if (action.equals("startSmsActivity")) {
JSONObject obj = args.getJSONObject(0);
String type = obj.has("message") ? obj.getString("message") : "";
startSmsActivity(type );
}
else if( action.equals("startEmailActivity") )
{
JSONObject obj = args.getJSONObject(0);
String msg = obj.has("message") ? obj.getString("message") : "";
String subject = obj.has("subject") ? obj.getString("subject") : "";
startEmailActivity(msg, subject );
}
else if( action.equals("startSocialActivity") )
{
JSONObject obj = args.getJSONObject(0);
String msg = obj.has("message") ? obj.getString("message") : "";
startSocialActivity(msg);
}
}
catch (JSONException e) {
e.printStackTrace();
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
}
PluginResult mPlugin = new PluginResult(PluginResult.Status.NO_RESULT);
mPlugin.setKeepCallback(true);
this.callback = callbackId;
return mPlugin;
}
public void startSmsActivity( String msg ) {
Uri uri = Uri.parse("smsto:");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body",msg );
this.ctx.startActivityForResult( (Plugin) this, it, 1 );
}
public void startEmailActivity ( String msg, String subject )
{
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
LOG.e("EmailComposer","empieza");
ArrayList<Uri> uris = new ArrayList<Uri>();
try {
//Uri should come as an parameter
File folder = new File(Environment.getExternalStorageDirectory(), "Directory");
//Uri should come as an parameter
File f = new File(folder, "screenshot_file.png");
if (f.exists()) {
LOG.e("EmailComposer","existe");
Uri uri = Uri.fromFile(f);
uris.add(uri);
}
} catch (Exception e) {
LOG.e("EmailComposer", "Error adding an attachment: " + e.toString());
}
final Intent emailIntent2 = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
// emailIntent.setType("text/plain");
emailIntent2.setType("message/rfc822");
emailIntent2.putExtra(Intent.EXTRA_SUBJECT, subject );
emailIntent2.putExtra(android.content.Intent.EXTRA_TEXT, msg );
emailIntent2.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);
// this.ctx.startActivity(emailIntent);
cordova.getActivity().startActivity(emailIntent2);
}
public void startSocialActivity ( String msg )
{
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg );
this.ctx.startActivity(Intent.createChooser(emailIntent, "Share Dead Tone in:"));
}
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
JSONObject smsObj = new JSONObject();
try {
smsObj.put("msg", "done");
} catch (JSONException e) {
e.printStackTrace();
}
this.success(new PluginResult(PluginResult.Status.OK,smsObj
), this.callback);
}
}
.js Should get attachment uri as a parameter.
var SocialShare = function() {}; var exec = cordova.require("cordova/exec"); SocialShare.prototype.sms = function(param, successCallback, failCallback) {
function success(args) {
successCallback(args);
}
function fail(args) {
failCallback(args);
}
return exec(function(args) {
success(args);
}, function(args) {
fail(args);
}, 'SocialShare', 'startSmsActivity', [param]);
};
SocialShare.prototype.email = function(param, successCallback, failCallback) {
function success(args) {
successCallback(args);
}
function fail(args) {
failCallback(args);
}
return exec(function(args) {
success(args);
}, function(args) {
fail(args);
}, 'SocialShare', 'startEmailActivity', [param]);
};
SocialShare.prototype.social = function(param, successCallback, failCallback) {
function success(args) {
successCallback(args);
}
function fail(args) {
failCallback(args);
}
return exec(function(args) {
success(args);
}, function(args) {
fail(args);
}, 'SocialShare', 'startSocialActivity', [param]);
};
.html Should get attachment uri as a parameter.
window.SocialShare.email({message:'Email body', subject: "Email Subject"}, function(msg) { alert("ok"); }, function(fail) {
}
);
Hi macdonst, Tried the video player plugin for Cordova 2.3.0 and still no success. Is there some changes that needs to be done to plugin for cordova 2.2.
Your help would be grately appreciated. Thanks
As long as you are using the one from the 2.2.0 directory there shouldn't be any issues.
https://github.com/macdonst/VideoPlayer/tree/master/2.2.0
Simon Mac Donald http://hi.im/simonmacdonald
On Wed, Feb 13, 2013 at 10:42 AM, mb202005 notifications@github.com wrote:
Hi macdonst, Tried the video player plugin for Cordova 2.3.0 and still no success. Is there some changes that needs to be done to plugin for cordova 2.2.
Your help would be grately appreciated. Thanks
— Reply to this email directly or view it on GitHubhttps://github.com/macdonst/VideoPlayer/issues/8#issuecomment-13499934.
Hi macdonst, i will be really gratefull if you could post an full project example for cordova 2.2.0, im trying to make it work but unsuccessfully. Please help.