use of org.storymaker.app.model.Project in project storymaker by StoryMaker.
the class PublishActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_publish);
Intent intent = getIntent();
String title = intent.getStringExtra(Constants.EXTRA_STORY_TITLE);
String storyPathInstancePath = intent.getStringExtra(Constants.EXTRA_STORY_INSTANCE_PATH);
StoryPathLibrary spl = getStoryPathLibrary(storyPathInstancePath);
if (title == null)
title = getString(R.string.no_title);
ArrayList<Parcelable> parcelables = intent.getParcelableArrayListExtra(Constants.EXTRA_EXPORT_CLIPS);
mProject = new Project(this, 1);
// FIXME this should be split into a method, probably in the model.Project class?
mProject = new Project(this, 1);
mProject.setTitle(title);
// FIXME can we leverage this for the story path file?
mProject.setTemplatePath("");
// until we iron out multi medium, we just tied export medium to the medium of the first clip
final String medium = ((FullMetadata) parcelables.get(0)).getMedium();
if (medium.equals("photo")) {
mProject.setStoryType(Project.STORY_TYPE_ESSAY);
} else if (medium.equals("audio")) {
mProject.setStoryType(Project.STORY_TYPE_AUDIO);
} else if (medium.equals("video")) {
mProject.setStoryType(Project.STORY_TYPE_VIDEO);
}
mProject.setTemplatePath(storyPathInstancePath);
if ((spl != null) && (spl.getPublishProfile() != null)) {
// FIXME move this into the actual publish step so the user doesn't remove them in the publishfragment info editor
mProject.setTagsFromStringList(spl.getPublishProfile().getTags());
}
mProject.save();
Scene scene = new Scene(this, parcelables.size());
scene.setTitle("ligerscene1");
scene.setProjectId(mProject.getId());
scene.setProjectIndex(0);
scene.save();
// FIXME convert export into project
int i = 0;
for (Parcelable p : parcelables) {
// index, cliptype, path, mimetype
FullMetadata m = ((FullMetadata) p);
float trimStartRatio = ((float) m.getStartTime()) / m.getDuration();
int trimStart = (int) (trimStartRatio * 100) - 1;
float trimEndRatio = ((float) m.getStopTime()) / m.getDuration();
int trimEnd = (int) (trimEndRatio * 100) - 1;
// FIXME hardcoded "video/mp4"
scene.setMedia(i, m.getFilePath(), m.getFilePath(), "video/mp4", trimStart, trimEnd, m.getDuration(), m.getVolume());
i++;
}
scene.save();
parcelables = intent.getParcelableArrayListExtra(Constants.EXTRA_EXPORT_AUDIOCLIPS);
if (parcelables != null) {
i = 0;
ArrayList<org.storymaker.app.model.AudioClip> audioClipModels = new ArrayList<org.storymaker.app.model.AudioClip>();
for (Parcelable p : parcelables) {
AudioClipFull audioClip = ((AudioClipFull) p);
org.storymaker.app.model.AudioClip ac = org.storymaker.app.model.AudioClip.getInstanceFromLigerAudioClip(this, audioClip, scene.getId(), audioClip.getPath());
ac.save();
// TODO this needs to add AudioClip' models to this scene
audioClipModels.add(ac);
}
}
// FIXME load project
mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject, null);
mMPM.initProject();
if (savedInstanceState == null) {
mPublishFragment = new PublishFragment();
Bundle args = new Bundle();
// args.putInt(AddClipsFragment.ARG_SECTION_NUMBER, tab.getPosition() + 1);
args.putInt("layout", R.layout.fragment_complete_story);
args.putInt("scene", 0);
mPublishFragment.setArguments(args);
getSupportFragmentManager().beginTransaction().add(R.id.container, mPublishFragment).commit();
}
}
use of org.storymaker.app.model.Project in project storymaker by StoryMaker.
the class PublisherBase method publishToStoryMaker.
public String publishToStoryMaker() {
Job job = getPreferredUploadJob();
Project project = mPublishJob.getProject();
String title = project.getTitle();
String desc = project.getDescription();
String mediaEmbed = getEmbed(job);
String[] categories = project.getCategories();
String medium = getMedium();
String mediaService = job.getSite();
// TODO get the id from the preferred job to publish to facebook
String mediaGuid = job.getResult();
try {
String ret = publishToStoryMaker(title, desc, mediaEmbed, categories, medium, mediaService, mediaGuid);
return ret;
} catch (IOException ioe) {
Timber.e(ioe, "failed to publish due to an IOException");
}
return null;
}
use of org.storymaker.app.model.Project in project storymaker by StoryMaker.
the class ArchiveUploader method start.
// FIXME move the render file checks into base class
@Override
public void start() {
final SiteController controller = SiteController.getSiteController(ArchiveSiteController.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, ArchiveSiteController.SITE_KEY);
if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_internet_archive));
HashMap<String, String> valueMap = publishJob.getMetadata();
addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
// FIXME need to hookup Account to this
controller.upload(auth.convertToAccountObject(), valueMap);
} else {
Timber.d("Can't upload to Internet Archive server, 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 Internet Archive server, last rendered file doesn't exist.");
}
}
use of org.storymaker.app.model.Project 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.Project in project storymaker by StoryMaker.
the class SSHPublisher method startRender.
public void startRender() {
Timber.d("startRender");
Project project = (Project) (new ProjectTable()).get(mContext, mPublishJob.getProjectId());
if (project.getStoryType() == Project.STORY_TYPE_VIDEO) {
Job videoRenderJob = new Job(mContext, mPublishJob.getProjectId(), mPublishJob.getId(), JobTable.TYPE_RENDER, null, VideoRenderer.SPEC_KEY);
mController.enqueueJob(videoRenderJob);
} else if (project.getStoryType() == Project.STORY_TYPE_AUDIO) {
Job videoRenderJob = new Job(mContext, mPublishJob.getProjectId(), mPublishJob.getId(), JobTable.TYPE_RENDER, null, AudioRenderer.SPEC_KEY);
mController.enqueueJob(videoRenderJob);
} else {
// skip render, no point
mController.publishJobSucceeded(mPublishJob, null);
}
}
Aggregations