use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.
the class PublishFragment method playClicked.
// private void purgePublishTables() {
// net.sqlcipher.database.SQLiteDatabase db = new StoryMakerDB(getActivity().getBaseContext()).getWritableDatabase("foo");
// (new PublishJobTable(db)).debugPurgeTable();
// (new JobTable(db)).debugPurgeTable();
// db.close();
// }
// public String postToStoryMaker (String title, String desc, String mediaEmbed, String[] categories, String medium, String mediaService, String mediaGuid) throws MalformedURLException, XmlRpcFault
// {
//
//
// ServerManager sm = StoryMakerApp.getServerManager();
// sm.setContext(mActivity.getBaseContext());
//
// Message msgStatus = mHandlerPub.obtainMessage(EditorBaseActivity.REQ_OVERLAY_CAM);
// msgStatus.getData().putString("status",
// getActivity().getString(R.string.uploading_to_storymaker));
// mHandlerPub.sendMessage(msgStatus);
//
// String descWithMedia = desc + "\n\n" + mediaEmbed;
// String postId = sm.post(title, descWithMedia, categories, medium, mediaService, mediaGuid); // FIXME this is burying an exception if the user skipping creating a StoryMaker.cc account
//
// String urlPost = sm.getPostUrl(postId);
// return urlPost;
//
// }
private void playClicked() {
// FIXME grab the last acceptable render and use it instead of this mFileLastExport junk
if (mFileLastExport != null && mFileLastExport.exists()) {
// FIXME replace this with a check to make sure render is suitable
mActivity.mMPM.mMediaHelper.playMedia(mFileLastExport, null);
} else {
mUploading = false;
mPlaying = true;
// purgePublishTables(); // FIXME DEBUG disable this once we fix the publish table bugs
// TODO default to a video spec render and kick it off
// create a dummy publishjob with no sites
showPlaySpinner(true);
PublishJob publishJob = new PublishJob(getActivity().getBaseContext(), mActivity.mProject.getId(), new String[] { "preview" }, null);
publishJob.save();
startRender(publishJob);
}
}
use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.
the class PublishFragment method jobSucceeded.
@Override
public void jobSucceeded(Job job) {
PublishJob publishJob = job.getPublishJob();
if (job.getType().equals(JobTable.TYPE_RENDER)) {
if (mPlaying) {
showUploadSpinner(false);
showPlaySpinner(false);
// FIXME this can be null
String path = publishJob.getLastRenderFilePath();
if (path != null) {
// FIXME this won't work when a upload job succeeds
mFileLastExport = new File(path);
Handler handlerTimer = new Handler();
mProgressText.setText("Complete!");
handlerTimer.postDelayed(new Runnable() {
public void run() {
showPlayAndUpload(true);
}
}, 200);
} else {
Timber.d("last rendered path is empty!");
}
if (mFileLastExport != null && mFileLastExport.exists()) {
// FIXME replace this with a check to make sure render is suitable
mActivity.mMPM.mMediaHelper.playMedia(mFileLastExport, null);
}
mPlaying = false;
}
if (mUploading) {
startUpload(publishJob);
}
} else if (job.getType().equals(JobTable.TYPE_UPLOAD)) {
// FIXME ???
}
}
use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.
the class RenderWorker method start.
public void start(PublishJob publishJob) {
// // TODO guard against multiple calls if we are running already
// // ArrayList<Job> jobs = (ArrayList<Job>) (new JobTable(db)).getUnfinishedAsList(context, JobTable.TYPE_UPLOAD);
// // SQLiteDatabase db = (new StoryMakerDB(context)).getWritableDatabase("foo");
// Job job = (new JobTable(null)).getNextUnfinished(mContext, JobTable.TYPE_RENDER, publishJob, null);
// RendererBase renderer = null;
// if (job != null) {
// if (job.isSpec(VideoRenderer.SPEC_KEY)) {
// renderer = new VideoRenderer(mContext, this, job);
// } else if (job.isSpec(AudioRenderer.SPEC_KEY)) {
// renderer = new AudioRenderer(mContext, this, job);
// } //else if (job.isSpec(Auth.SITE_STORYMAKER)) {
// // renderer = new StoryMakerUploader(context, this, job);
// // }
// renderer.start();
// }
// TODO guard against multiple calls if we are running already
// Job job = (new JobTable(null)).getNextUnfinished(mContext, JobTable.TYPE_RENDER, publishJob, null);
// this should just just grab the new job, ignore old ones for now
// FIXME extend this to multiple render jobs, for now its hard coded to 1 at a time
ArrayList<Job> jobs = publishJob.getRenderJobsAsList();
if (jobs != null && jobs.size() > 0) {
Job job = jobs.get(0);
RendererBase renderer = null;
if (job != null) {
if (job.isSpec(VideoRenderer.SPEC_KEY)) {
renderer = new VideoRenderer(mContext, this, job);
} else if (job.isSpec(AudioRenderer.SPEC_KEY)) {
renderer = new AudioRenderer(mContext, this, job);
}
// FIXME need a slideshow renderer?
renderer.start();
}
} else {
jobFailed(null, null, 98129129, "No render job in db");
}
}
use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.
the class FacebookUploader method start.
// FIXME move the render file checks into base class
@Override
public void start() {
// TODO Auto-generated constructor stub
final SiteController controller = SiteController.getSiteController(FacebookSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
final Project project = mJob.getProject();
final PublishJob publishJob = mJob.getPublishJob();
final String path = publishJob.getLastRenderFilePath();
final Auth auth = (new AuthTable()).getAuthDefault(mContext, FacebookSiteController.SITE_KEY);
if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
Handler mainHandler = new Handler(mContext.getMainLooper());
Runnable myRunnable = new Runnable() {
// facebook seems to freak out if our service's looper is dead when it tries to send message back
@Override
public void run() {
jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_facebook));
HashMap<String, String> valueMap = publishJob.getMetadata();
// need to extract raw photos
// what happened to STORY_TYPE_PHOTO?
// TODO: currently checking preferences, will revisit when ui is updated
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mContext);
boolean uploadPhotos = sharedPref.getBoolean("pphotoformat", false);
if ((publishJob.getProject().getStoryType() == Project.STORY_TYPE_ESSAY) && uploadPhotos) {
ArrayList<Media> photos = publishJob.getProject().getMediaAsList();
String photoString = "";
for (Media photo : photos) {
photoString = photoString + photo.getPath() + ";";
}
// drop trailing ;
photoString = photoString.substring(0, photoString.length() - 1);
valueMap.put(FacebookSiteController.PHOTO_SET_KEY, photoString);
}
addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
controller.upload(auth.convertToAccountObject(), valueMap);
}
};
mainHandler.post(myRunnable);
} else {
Timber.d("Can't upload to facebook, last rendered file doesn't exist.");
// TODO get this error back to the activity for display
// FIXME move to strings.xml
jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to facebook, last rendered file doesn't exist.");
}
}
use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.
the class SoundCloudUploader method start.
// FIXME move the render file checks into base class
@Override
public void start() {
// TODO Auto-generated constructor stub
final SiteController controller = SiteController.getSiteController(SoundCloudSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
final Project project = mJob.getProject();
final PublishJob publishJob = mJob.getPublishJob();
final String path = publishJob.getLastRenderFilePath();
final Auth auth = (new AuthTable()).getAuthDefault(mContext, SoundCloudSiteController.SITE_KEY);
// FIXME deal with lack of auth credentials here
if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
Handler mainHandler = new Handler(mContext.getMainLooper());
Runnable myRunnable = new Runnable() {
// facebook seems to freak out if our service's looper is dead when it tries to send message back
@Override
public void run() {
jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_soundcloud));
HashMap<String, String> valueMap = publishJob.getMetadata();
addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
controller.upload(auth.convertToAccountObject(), valueMap);
}
};
mainHandler.post(myRunnable);
} else {
Timber.d("Can't upload to SoundCloud, last rendered file doesn't exist.");
// TODO get this error back to the activity for display
// FIXME move to strings.xml
jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to SoundCloud, last rendered file doesn't exist.");
}
}
Aggregations