Search in sources :

Example 1 with AudioClipFull

use of scal.io.liger.model.AudioClipFull 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)

Aggregations

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