Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 添加到媒体库插件的“应用链接播放”按钮_Php_Video_Media Player_Gallery_Modal Dialog - Fatal编程技术网

Php 添加到媒体库插件的“应用链接播放”按钮

Php 添加到媒体库插件的“应用链接播放”按钮,php,video,media-player,gallery,modal-dialog,Php,Video,Media Player,Gallery,Modal Dialog,我正在建立一个网站,使用一个插件来创建一个画廊查看视频饲料。在生成gallery视图的PHP文件中,我添加了一个播放按钮,显示在视频缩略图的顶部。当按钮正确显示时,插件将视频链接直接应用于缩略图图像,因此如果用户直接单击按钮,它不会打开视频模式 <div class="media-thumb videoPreviewBox"> <div class="videoPreview"> </a><img src="<?php

我正在建立一个网站,使用一个插件来创建一个画廊查看视频饲料。在生成gallery视图的PHP文件中,我添加了一个播放按钮,显示在视频缩略图的顶部。当按钮正确显示时,插件将视频链接直接应用于缩略图图像,因此如果用户直接单击按钮,它不会打开视频模式

<div class="media-thumb videoPreviewBox">
    <div class="videoPreview">
        </a><img src="<?php   echo $image_path?>" href="#popup_prep" alt="<?php  echo $file_src?>" class="<?php  echo $playerID?>player_get<?php  echo $i?> gallery_thumb" href="<?php  echo $file_src?>"/>
        <img class="playButtonHover" src="<?php echo $this->getThemePath()?>/images/playButtonHover.png">
        <img class="playButton" src="<?php echo $this->getThemePath()?>/images/playButton.png">
    </div>
</div>
以及完整的PHP gallery视图文件:

<?php   
    defined('C5_EXECUTE') or die(_("Access Denied."));
    $btID = $b->getBlockTypeID();
    $bt = BlockType::getByID($btID);
    $uh = Loader::helper('concrete/urls');
    $rssUrl = $controller->getRssUrl($b);
    $textHelper = Loader::helper("text"); 
    $fl = Loader::model('file_version');
    $uh = Loader::helper('concrete/urls');
    $mh = Loader::helper('media_type','promedia');
    $bt = BlockType::getByHandle('promedia_list');
    $height = '400';
    $width = '600';
    $spread = 4;
    $playerID = rand(0,777777);

    if (count($cArray) > 0) { ?>
    <div class="scroller">
    <div id="media_galery">
    <?php  
    $t = 0;

            for ($i = 0; $i < count($cArray); $i++ ) {
                $t++;
                $file = $cArray[$i];
                $remote = null;
                $name = $file->getFileName();
                $file_path = BASE_URL.DIR_REL.$file->getDownloadURL();
                $ak_d = FileAttributeKey::getByHandle('media_date'); 
                $date = $file->getAttribute($ak_d);

                $ak_a = FileAttributeKey::getByHandle('media_artwork'); 
                $image = $file->getAttribute($ak_a);
                if($image==null){
                    $image_path=$uh->getBlockTypeAssetsURL($bt).'/tools/mp3.png';
                }else{
                    $image = File::getByID($image->fID);
                    $image_path=$image->getURL();
                }


                $file_src = BASE_URL.DIR_REL.$file->getRelativePath();

                $ak_s = FileAttributeKey::getByHandle('media_audio'); 
                $audio = $file->getAttribute($ak_s);
                if($audio){
                    $audio_array = $mh->getMediaTypeOutput($audio);
                    $audio_path = $audio_array['path'];
                    $file_src = $audio_path;
                }

                $video = null;
                $ak_s = FileAttributeKey::getByHandle('media_video'); 
                $video = $file->getAttribute($ak_s);

                if($video){
                    $video_array = $mh->getMediaTypeOutput($video);
                    $video_path = $video_array['path'];
                    //var_dump($video_array['id']);
                    $image_path = $mh->getMediaThumbnail($video_array['id'],$video_array['type']);
                    //$video_src = $video_path.'?width='.$width.'&height='.$height;
                    //$file_src = $video_src;
                    if($video_array['type'] == 'vimeo'){
                        $file_src = 'http://player.vimeo.com/video/'.$video_array['id'];
                    }else{
                        $file_src = $video_path;
                    }
                }
                ?>
                <div class="media-thumb videoPreviewBox">
                    <div class="videoPreview">
                        </a><img src="<?php   echo $image_path?>" href="#popup_prep" alt="<?php  echo $file_src?>" class="<?php  echo $playerID?>player_get<?php  echo $i?> gallery_thumb" href="<?php  echo $file_src?>"/>
                        <img class="playButtonHover" src="<?php echo $this->getThemePath()?>/images/playButtonHover.png">
                        <img class="playButton" src="<?php echo $this->getThemePath()?>/images/playButton.png">
                    </div>
                </div>
            <?php  
            if($t == $spread){
                $t=0;
                echo '</tr>';
            }
    }

    for($d=$t;$d<$spread;$d++){
        echo '<td></td>';
        if($t == $spread){
            echo '</tr>';
        }
    }
    ?>
    </div>
    </div>
    <div style="display: none;">
        <div id="popup_prep">

        </div>
    </div>
    <script type="text/javascript">
    /*<![CDATA[*/
    $(document).ready(function() {
        $('.gallery_thumb').fancybox({
            width: 'auto',
            height: 'auto',
            onClosed: function(){
                $('video, audio').each(function() {
                  $(this)[0].player.pause();          
                });
            }
        });
    });
    /*]]>*/
    </script>
    <script type="text/javascript">
    /*<![CDATA[*/
    $('.gallery_thumb').click(function(){
        $('#popup_prep').html('');
        var html = '';
        var path = $(this).attr('alt');
        //console.log(path);
        var extension = path.substr( (path.lastIndexOf('.') +1) );

        if(extension){
            switch(extension) {
                case 'm4v':  
                case 'mpeg':
                case 'mpg':
                case 'wmv':
                case 'avi':
                case 'mov':
                case 'flv':
                case 'f4v':
                case 'mp4':
                  html = '<video class="player_box" id="play" controls="controls" src="'+path+'" width="<?php  echo $width?>" height="<?php  echo $height?>"></video><br style="clear: both;"/>';
                  break;    
                case 'mp3':
                case 'm4a':
                  html = '<audio class="audioplayer" id="play"  src="'+path+'" controls="controls" type="audio/m4a"></audio><br style="clear: both;"/>';
                  break;   
                default:
                  var iFrame = true;
                  html = '<iframe title="video player" width="<?php  echo $width?>px" height="<?php  echo $height?>px" src="'+path+'" frameborder="0" allowfullscreen></iframe>'; 
            }
        }
        $('#popup_prep').append(innerShiv(html));
        if(!iFrame){
            var player = new MediaElementPlayer('video,audio');
        }
    });
    /*]]>*/
    </script>
    <?php   

    } 
    if(!$previewMode && $controller->rss) { 
            ?>
            <div class="rssIcon">
                <img src="<?php   echo $uh->getBlockTypeAssetsURL($bt, 'rss.png')?>" width="14" height="14" /><a href="<?php   echo $rssUrl?>" target="_blank">get this feed</a>

            </div>
            <link href="<?php   echo $rssUrl?>" rel="alternate" type="application/rss+xml" title="<?php   echo $controller->rssTitle?>" />
            <br/>
        <?php   
    } 


    if ($paginate && $num > 0 && is_object($_fl)) {
        $_fl->displayPaging();
    }

?>

“href=“#popup_prep”alt=”“class=“player_get gallery_thumb”href=”“/>
getThemePath()?>/images/playButtonHover.png“>
getThemePath()?>/images/playButton.png“>
/**/

/* 我并不完全是php专家,但我注意到这行代码中存在一些问题:

</a><img src="<?php   echo $image_path?>" href="#popup_prep" alt="<?php  echo $file_src?>" class="<?php  echo $playerID?>player_get<?php  echo $i?> gallery_thumb" href="<?php  echo $file_src?>"/>
img src="<?php echo $image_path ?>" href="<?php  echo $file_src ?>" alt="YOUR DESCRIPTION HERE" class="<?php echo $playerID ?>player_get<?php echo $i ?>gallery_thumb">
“href=“#popup_prep”alt=”“class=“player_get gallery_thumb”href=”“/>
首先,我不知道为什么会有一个“/a”。这通常是超链接的结束标记。(如果我把它放在那里,它会从答案中消失,并像html一样被读取,所以让我们假设“”与相同)

其次,看起来你把href和alt的引号里的东西弄混了。href是链接,alt是描述。除非您希望描述与图像链接相同,但我建议使用更合适的描述,例如alt=“Play Video”

第三,检查类中的空格数。例如,如果$playerID=“123”和$i=1。该类将如下所示:123player_get1 gallery_thumb(注意$i或本例中的数字1与gallery_thumb之间的空格)。我可能又错了,但我不认为应该有空间,可以通过消除结束php标记旁边的空间来修复

第四,您在这个img标签中有两个href=”“。就像我说的,我不是专家,但我假设第一个不需要在那里,而且可能会造成麻烦,因为href是点击图像时会带你去的链接

第五,我不确定这是否真的重要,但通常img标签的末尾没有/>,它只需要一个>

尝试将其替换为这行代码:

</a><img src="<?php   echo $image_path?>" href="#popup_prep" alt="<?php  echo $file_src?>" class="<?php  echo $playerID?>player_get<?php  echo $i?> gallery_thumb" href="<?php  echo $file_src?>"/>
img src="<?php echo $image_path ?>" href="<?php  echo $file_src ?>" alt="YOUR DESCRIPTION HERE" class="<?php echo $playerID ?>player_get<?php echo $i ?>gallery_thumb">
img src=”“href=”“alt=“您在这里的描述”class=“player\u getgallery\u thumb”>


*编辑:如果有效,请确保您了解原因