MeiCam SDK For Android  3.1.2
Template instructions

Template instructions

  Meishe template resource package needs to be used by three steps: Installing, catching the template information, setting the timeline. This instruction is only suitable for Android, but IOS need to refer other relevant docs.

1、Installing

  Same as other resource package, to call the “install” interface to install which can be finding in the “assetPackageManager”. But template installing must be ** Asynchronous installation, installation completion callback.**

StringBuilder fx = new StringBuilder();
mStreamingContext.getAssetPackageManager().installAssetPackage(
    “assets:/FD76F889-8093-4757-B0FA-4FAE66273451.template”,
    null,
    NvsAssetPackageManager.ASSET_PACKAGE_TYPE_TEMPLATE,
    false,
    fx);

2、Setting the template frame percentage (unnecessary step)

  Template can support multiple pictures. If you want to use non-default picture. It can call “changeTemplateAspectRatio" interface ("assetPackageManage") to set the required template picture:

public boolean changeTemplateAspectRatio(String uuidString, int aspectRatio)

  The picture percentage supported by the template can be through as “changeTemplateAspectRatio" ("assetPackageManage") interface to check:

public int getAssetPackageSupportedAspectRatio(String assetPackageId, int type)

3、Collecting the template information

  Calling the relevant interface in “assetPackageManager” to gain the template information. It provides a list of materials to get the template from and a list of substitutable captions for template. According to the product needs, it can increase the relevant interface to gain the template information.

3.1、Collecting template material form:

  Call “getTemplateFootages” interface, import UUID of the installed template resource package, callback the template material form.

List<NvsAssetPackageManager.NvsTemplateFootageDesc> list =
m_streamingContext.getAssetPackageManager().getTemplateFootages(templateId);

  Material information:

public static final int TEIMPLATE_FOOTAGE_TYPE_VIDEO_IMAGE = 0;
public static final int TEIMPLATE_FOOTAGE_TYPE_VIDEO = 1;
public static final int TEIMPLATE_FOOTAGE_TYPE_IMAGE = 2;
public static final int TEIMPLATE_FOOTAGE_TYPE_AUDIO = 3;
public static final int TEIMPLATE_FOOTAGE_TYPE_FAEEZE_FRAME = 4;

public static class NvsTemplateFootageCorrespondingClipInfo 
{
    public int trackIndex;
    public int clipIndex;
    public long inpoint
    public long outpoint
    public boolean needReverse;
    public boolean canReplace;
}

public static class NvsTemplateFootageDesc 
{
    public String id;
    public int type;
    public boolean canReplace;
    public String innerAssetFilePath;
    public ArrayList<String> tags;  
    public ArrayList<NvsTemplateFootageCorrespondingClipInfo> correspondingClipInfos;
}

3.2、Collecting the template substitutable caption form:

  Call “getTemplateCaptions” interface, import the UUID of the installed template resource package, callback the template substitutable caption form:

List<NvsAssetPackageManager.NvsTemplateCaptionDesc> arrayList =
m_streamingContext.getAssetPackageManager().getTemplateCaptions(templateId);

  Caption information:

public static class NvsTemplateCaptionDesc 
{
    public String replaceId;   //Caption ID
    public String text;       //Text content of Caption
}

  If you need to replace the text content, so need to be traversal timeline’s caption object. Finding the caption object id and “replaced” matched caption object, and then call “setText” to set the text content in caption.

List<NvsAssetPackageManager.NvsTemplateCaptionDesc> captions = m_streamingContext.getAssetPackageManager().getTemplateCaptions(templateId);

NvsTimelineCaption caption = timeline.getFirstCaption();
while (caption != null) 
{
    String id = caption.getTemplateAttachment(NvsObject.TEMPLATE_KEY_REPLACE_ID);

    if(captions.get(0).replaceId.equals(id)) 
    {
        caption.setText(“test”);
        break;
    }

    caption = m_timeline.getNextCaption(caption);
}

4、Setting timeline

  Using the method of “createTimeline” to call “streamingContext”, import the UUID of the installed template resource package, and need to replace “footage” form, callback the Timeline corresponding to the template.

public NvsTimeline createTimeline(String templateId, List<templateFootageInfo> templateFootages);

public static class templateFootageInfo
{
    public String footageId;        // footage ID
    public String filePath;         // File path corresponding to footage
    public String reverseFilePath;  // Reverse file path corresponding to footage
}

  So far, Application layer can play this timeline, or start a second editing.