Example usage for org.apache.poi.hslf.record InteractiveInfoAtom ACTION_MEDIA

List of usage examples for org.apache.poi.hslf.record InteractiveInfoAtom ACTION_MEDIA

Introduction

In this page you can find the example usage for org.apache.poi.hslf.record InteractiveInfoAtom ACTION_MEDIA.

Prototype

byte ACTION_MEDIA

To view the source code for org.apache.poi.hslf.record InteractiveInfoAtom ACTION_MEDIA.

Click Source Link

Usage

From source file:poi.hslf.examples.SoundFinder.java

License:Apache License

/**
 * Check if a given shape is associated with a sound.
 * @return 0-based reference to a sound in the sound collection
 * or -1 if the shape is not associated with a sound
 *///from   www .  j a  v a 2  s .c  o  m
protected static int getSoundReference(Shape shape) {
    int soundRef = -1;
    //dive into the shape container and search for InteractiveInfoAtom
    EscherContainerRecord spContainer = shape.getSpContainer();
    List spchild = spContainer.getChildRecords();
    for (Iterator it = spchild.iterator(); it.hasNext();) {
        EscherRecord obj = (EscherRecord) it.next();
        if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
            byte[] data = obj.serialize();
            Record[] records = Record.findChildRecords(data, 8, data.length - 8);
            for (int j = 0; j < records.length; j++) {
                if (records[j] instanceof InteractiveInfo) {
                    InteractiveInfoAtom info = ((InteractiveInfo) records[j]).getInteractiveInfoAtom();
                    if (info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) {
                        soundRef = info.getSoundRef();
                    }
                }
            }
        }
    }
    return soundRef;
}