Search in sources :

Example 1 with FullMetadata

use of scal.io.liger.model.FullMetadata 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();
    }
}
Also used : MediaProjectManager(org.storymaker.app.media.MediaProjectManager) FullMetadata(scal.io.liger.model.FullMetadata) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Parcelable(android.os.Parcelable) AudioClipFull(scal.io.liger.model.AudioClipFull) Scene(org.storymaker.app.model.Scene) Project(org.storymaker.app.model.Project) StoryPathLibrary(scal.io.liger.model.StoryPathLibrary)

Example 2 with FullMetadata

use of scal.io.liger.model.FullMetadata in project storymaker by StoryMaker.

the class SceneEditorActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    //project id
    int pid = intent.getIntExtra("pid", -1);
    ArrayList<Parcelable> parcelables = intent.getParcelableArrayListExtra(Constants.EXTRA_EXPORT_CLIPS);
    mSceneIndex = getIntent().getIntExtra("scene", 0);
    if (parcelables != null) {
        // FIXME this should be split into a method, probably in the model.Project class?
        mProject = new Project(this, 1);
        mProject.setTitle("export from liger");
        mProject.setTemplatePath("");
        mProject.setStoryType(Project.STORY_TYPE_VIDEO);
        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);
            scene.setMedia(i, m.getFilePath(), m.getFilePath(), "video/mp4");
            i++;
        }
        scene.save();
        // FIXME load project
        mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject, scene);
    } else if (pid != -1) {
        // FIXME ugly
        mProject = (Project) (new ProjectTable()).get(getApplicationContext(), pid);
        Scene scene = null;
        if ((mSceneIndex != -1) && (mSceneIndex < mProject.getScenesAsArray().length)) {
            scene = mProject.getScenesAsArray()[mSceneIndex];
        }
        mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject, scene);
        mMPM.initProject();
    } else {
        // FIXME get rid of hardcoded clipCount = 5
        int clipCount = 5;
        String title = intent.getStringExtra("title");
        mProject = new Project(getApplicationContext(), clipCount);
        mProject.setTitle(title);
        mProject.save();
        mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject);
        mMPM.initProject();
    }
    try {
        if (mProject.getScenesAsList().size() > 1) {
            mTemplate = Template.parseAsset(this, mProject.getTemplatePath(), Project.getSimpleTemplateForMode(getApplicationContext(), mProject.getStoryType()));
        } else {
            mTemplate = Template.parseAsset(this, Project.getSimpleTemplateForMode(getApplicationContext(), mProject.getStoryType()));
        }
    } catch (Exception e) {
        Timber.e(e, "could not parse templates");
    }
    setContentView(R.layout.activity_scene_editor_no_swipe);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    addPublishFragement();
    actionBar.setTitle(getString(R.string.tab_publish));
    if (intent.hasExtra("auto_capture") && intent.getBooleanExtra("auto_capture", false)) {
        openCaptureMode(0, 0);
    }
}
Also used : Project(org.storymaker.app.model.Project) MediaProjectManager(org.storymaker.app.media.MediaProjectManager) FullMetadata(scal.io.liger.model.FullMetadata) Intent(android.content.Intent) Parcelable(android.os.Parcelable) Scene(org.storymaker.app.model.Scene) ProjectTable(org.storymaker.app.model.ProjectTable) IOException(java.io.IOException) ActionBar(android.app.ActionBar)

Aggregations

Intent (android.content.Intent)2 Parcelable (android.os.Parcelable)2 MediaProjectManager (org.storymaker.app.media.MediaProjectManager)2 Project (org.storymaker.app.model.Project)2 Scene (org.storymaker.app.model.Scene)2 FullMetadata (scal.io.liger.model.FullMetadata)2 ActionBar (android.app.ActionBar)1 Bundle (android.os.Bundle)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ProjectTable (org.storymaker.app.model.ProjectTable)1 AudioClipFull (scal.io.liger.model.AudioClipFull)1 StoryPathLibrary (scal.io.liger.model.StoryPathLibrary)1