public function getVideoTextTrackContent(MediaInformation $media, $id)
    {
        $id = (int)$id;
        $record = $media->getResource()->get_record();
        $videoTextTrack = false;

        if ($record->getType() === 'video') {
            $databox = $record->getDatabox();
            $vttIds = [];

            // list available vtt ids
            foreach ($databox->get_meta_structure() as $meta) {
                if (preg_match('/^VideoTextTrack(.*)$/iu', $meta->get_name(), $foundParts)) {
                    $vttIds[] = $meta->get_id();
                }
            }

            // extract vtt content from ids
            foreach ($record->get_caption()->get_fields(null, true) as $field) {
                // if a category is matching, ensure it's vtt related
                if (!in_array($id, $vttIds) || $id !== $field->get_meta_struct_id()) {
                    continue;
                }

                foreach ($field->get_values() as $value) {
                    // get vtt raw content
                    $videoTextTrack = $value->getValue();
                }
            }
        }

        return $videoTextTrack;
    }
public function getVideoTextTrackContent(MediaInformation $media, $id)
    {
        $id = (int)$id;
        $record = $media->getResource()->get_record();
        $videoTextTrack = false;

        if ($record->getType() === 'video') {
            $databox = $record->getDatabox();
            $vttIds = [];

            // list available vtt ids
            foreach ($databox->get_meta_structure() as $meta) {
                if (preg_match('/^VideoTextTrack(.*)$/iu', $meta->get_name(), $foundParts)) {
                    $vttIds[] = $meta->get_id();
                }
            }

            // extract vtt content from ids
            foreach ($record->get_caption()->get_fields(null, true) as $field) {
                // if a category is matching, ensure it's vtt related
                if (!in_array($id, $vttIds) || $id !== $field->get_meta_struct_id()) {
                    continue;
                }

                foreach ($field->get_values() as $value) {
                    // get vtt raw content
                    $videoTextTrack = $value->getValue();
                }
            }
        }

        return $videoTextTrack;
    }
public function getVideoTextTrackContent ( MediaInformation $ media , $ id ) { $ id = ( int ) $ id ; $ record = $ media -> getResource ( ) -> get_record ( ) ; $ videoTextTrack = false ; if ( $ record -> getType ( ) === 'video' ) { $ databox = $ record -> getDatabox ( ) ; $ vttIds = [ ] ; // list available vtt ids foreach ( $ databox -> get_meta_structure ( ) as $ meta ) { if ( preg_match ( '/^VideoTextTrack(.*)$/iu' , $ meta -> get_name ( ) , $ foundParts ) ) { $ vttIds [ ] = $ meta -> get_id ( ) ; } } // extract vtt content from ids foreach ( $ record -> get_caption ( ) -> get_fields ( null , true ) as $ field ) { // if a category is matching, ensure it's vtt related if ( ! in_array ( $ id , $ vttIds ) || $ id !== $ field -> get_meta_struct_id ( ) ) { continue ; } foreach ( $ field -> get_values ( ) as $ value ) { // get vtt raw content $ videoTextTrack = $ value -> getValue ( ) ; } } } return $ videoTextTrack ; }
Fetch vtt files content if exists
@param MediaInformation $media
@return bool|string Video Text Track content
Fetch vtt files content if exists