Help with installing a videojs plugin

Hello

I have no experience here but I came to ask for help if anyone is willing. I have not posted anything yet because of the guidelines and first want to make sure it is alright. I am using open source software besides videojs.

No need to be worried, we’re a pretty friendly bunch here :slight_smile: Still, we’re more about helping people complete the freeCodeCamp learning curriculum; help with general programming problems will vary depending on your problem.

More specifics would help: which plugin are you trying to install? What code have you tried? What isn’t working (be specific, like paste any error messages), or which step isn’t clear?

Thanks for the warm welcome :joy:.

I am using a video sharing script called cumulusclips as a video archive for the site I am building. This script use’s Videojs for every different video but a different url like youtube mostly. I want to add the theater mode plugin but am having some problems getting the ID right.

Here is the phtml code I have for the page:

<?php
if ($playlist) $this->addBodyClass('is-playlist');
$this->addMeta('videoId', $video->videoId);
$this->addMeta('theme', $this->options->themeUrl);
$this->addMeta('loggedIn', (boolean) $loggedInUser);
$this->addCss('video-js.css');
$this->addCss('video-theatermode.css');
$this->addCss('scrollbar.css');
$this->addJs('video.plugin.js');
$this->addJs('video.theatermode.js');
$this->addJs('scrollbar.js');
$this->setLayout('full');
?>

<div class="row">

    <div class="col-md-8 play-left">

        <div class="alert hidden"></div>



        <!-- BEGIN Video Player -->
        <?php if ($video->gated && !$loggedInUser): ?>

            <div id="player-gated">
                <img width="750" height="420" src="<?=$config->thumbUrl?>/<?=$video->filename?>.jpg" alt="" />
                <div>
                    <p><?=Language::getText('gated_video')?></p>
                    <a href="<?=BASE_URL?>/login/" class="button_small"><?=Language::getText('login')?></a>
                    <?php if ($config->enableRegistrations): ?>
                        <a href="<?=BASE_URL?>/register/" class="button_small"><?=Language::getText('register')?></a>
                    <?php endif; ?>
                </div>
            </div>

        <?php else: ?>

            <div class="video-player-container">
                <video id="video-player" class="video-js vjs-default-skin vjs-16-9" data-setup='{ "controls": true, "autoplay": true, "preload": "auto" }' width="750" height="420" poster="<?=$config->thumbUrl?>/<?=$video->filename?>.jpg">
                    <source src="<?=$config->h264Url?>/<?=$video->filename?>.mp4" type="video/mp4" />
                    <?php if ($webmEncodingEnabled): ?>
                        <source src="<?=$config->webmUrl?>/<?=$video->filename?>.webm" type="video/webm" />
                    <?php endif; ?>
                    <?php if ($theoraEncodingEnabled): ?>
                        <source src="<?=$config->theoraUrl?>/<?=$video->filename?>.ogg" type="video/ogg" />
                    <?php endif; ?>
                </video>
           </div>

        <?php endif; ?>
        <!-- END Video Player -->



        <!-- BEGIN Playlist -->
        <?php if ($playlist): ?>
            <div id="playlist">
                <header>
                    <a class="playlist-collapse pull-right hidden-lg" href="#playlist .video-list" data-toggle="collapse">
                        <span class="glyphicon glyphicon-triangle-bottom"></span>
                    </a>
                    <h5><?=Functions::cutOff($this->getService('Playlist')->getPlaylistName($playlist), 85)?></h5>
                    <?php $playlistAuthor = $this->getMapper('User')->getUserById($playlist->userId); ?>
                    <p class="small">
                        <span class="author"><?=Language::getText('by')?>: <a href="<?=BASE_URL?>/members/<?=$playlistAuthor->username?>/"><?=$playlistAuthor->username?></a></span>
                        <?=Language::getText('videos')?>: <?=count($playlistVideos)?>
                    </p>
                </header>

                <div class="scrollbar-outer">
                    <div class="video-list collapse in">
                    <?php $videoService = $this->getService('Video'); ?>
                    <?php foreach ($playlistVideos as $playlistVideo): ?>

                        <div class="video video-small media <?=($playlistVideo->videoId == $video->videoId) ? 'active' : ''?>">
                            <div class="media-left thumbnail">
                                <a href="<?=$videoService->getUrl($playlistVideo)?>/?playlist=<?=$playlist->playlistId?>" title="<?=$playlistVideo->title?>">
                                    <span class="glyphicon glyphicon-play"></span>
                                    <img class="media-object" width="100" height="56" src="<?=$config->thumbUrl?>/<?=$playlistVideo->filename?>.jpg" />
                                </a>
                            </div>
                            <div class="media-body">
                                <p class="media-heading"><a href="<?=$videoService->getUrl($playlistVideo)?>/?playlist=<?=$playlist->playlistId?>" title="<?=$playlistVideo->title?>"><?=$playlistVideo->title?></a></p>
                                <div class="small">
                                    <?=Language::getText('by')?>:</strong> <a href="<?=BASE_URL?>/members/<?=$playlistVideo->username?>/" title="<?=$playlistVideo->username?>"><?=$playlistVideo->username?></a>
                                    <span class="duration"><span class="glyphicon glyphicon-time"></span> <?=$playlistVideo->duration?></span>
                                </div>
                            </div>
                        </div>
                    <?php endforeach; ?>
                    </div>
                </div>
            </div>
        <?php endif; ?>
        <!-- END Playlist -->



        <!-- BEGIN Actions -->
        <div class="panel panel-default actions">
            <div class="panel-body row">

                <div class="col-xs-12">
                    <h1><?=$video->title?></h1>
                </div>

                <div class="col-xs-6">
                    
                    <p>
                        <span class="like">
                            <span class="glyphicon glyphicon-thumbs-up"></span>
                            <?=$rating->likes?>
                        </span>
                        <span class="dislike">
                            <span class="glyphicon glyphicon-thumbs-down"></span>
                            <?=$rating->dislikes?>
                        </span>
                    </p>
                </div>

                <div class="col-xs-6 text-right">
                    <a class="rating" href="" data-video="<?php echo $video->videoId; ?>" data-rating="1" title="<?=Language::getText('like')?>">
                        <span class="glyphicon glyphicon-thumbs-up"></span>
                        <?=Language::getText('like')?>
                    </a>
                    <a class="rating" href="" data-video="<?php echo $video->videoId; ?>" data-rating="0" title="<?=Language::getText('dislike')?>">
                        <span class="glyphicon glyphicon-thumbs-down"></span>
                        <?=Language::getText('dislike')?>
                    </a>
                </div>

            </div>
        </div>
        <!-- END Actions -->



        <!-- BEGIN Action Tabs -->
        <ul class="nav nav-tabs">
            <li><a href="#about" data-toggle="tab"><?=Language::getText('about')?></a></li>
            <li><a href="#share" data-toggle="tab"><?=Language::getText('share')?></a></li>
            <li><a href="#add-to-playlist" data-toggle="tab" id="playlist-toggle"><?=Language::getText('add')?></a></li>
            <li><a href="" class="flag" data-type="video" data-id="<?=$video->videoId?>"><?=Language::getText('flag')?></a></li>
        </ul>
        <!-- END Action Tabs -->



        <!-- BEGIN Tab Panes -->
        <div class="tab-content">

            <!-- BEGIN About Tab -->
            <div class="tab-pane" id="about">
                <h4><?=Language::getText('about')?></h4>

                <div class="panel panel-default">
                    <div class="panel-body row">

                        <div class="col-xs-12 col-sm-10 media">
                            <div class="media-left">
                                <?php $avatar = $this->getService('User')->getAvatarUrl($member); ?>
                                <img class="media-object" width="65" height="65" src="<?=($avatar) ? $avatar : $this->options->themeUrl . '/images/avatar.gif'?>" alt="<?=$member->username?>" />
                            </div>
                            <div class="media-body">
                                <p><strong><?=Language::getText('by')?>:</strong> <a href="<?=BASE_URL?>/members/<?=$member->username?>/" title="<?=$member->username?>"><?=$member->username?></a></p>
                                <p><strong><?=Language::getText('date_uploaded')?>:</strong> <?=date('m/d/Y', strtotime($video->dateCreated))?></p>
                                <p><strong><?=Language::getText('tags')?>:</strong>
                                    <?php foreach ($video->tags as $value): ?>
                                        <a href="<?=BASE_URL?>/search/?keyword=<?=$value?>" title="<?=$value?>"><?=$value?></a>&nbsp;&nbsp;
                                    <?php endforeach; ?>
                                </p>

                                <?php if (!empty($attachments)): ?>
                                    <p><strong><?=Language::getText('attachments')?>:</strong>
                                        <?php foreach ($attachments as $attachment): ?>
                                            <a
                                                class="attachment"
                                                href="<?php echo $this->getService('File')->getUrl($attachment); ?>"
                                                title="<?php echo htmlspecialchars($attachment->name); ?> (<?php echo \Functions::formatBytes($attachment->filesize, 0); ?>)"
                                            ><i class="glyphicon glyphicon-paperclip"></i>
                                                <?php echo htmlspecialchars($attachment->name); ?> (<?php echo \Functions::formatBytes($attachment->filesize, 0); ?>)
                                            </a>
                                        <?php endforeach; ?>
                                    </p>
                                <?php endif; ?>

                            </div>

                        </div>
                        <div class="col-xs-12 col-sm-2">
                            <a href="" class="btn btn-primary subscribe" title="<?=Language::getText($subscribe_text)?>" data-type="<?=$subscribe_text?>" data-user="<?=$video->userId?>"><?=Language::getText($subscribe_text)?></a>
                        </div>

                        <p class="col-xs-12"><?=$video->description?></p>

                    </div>
                </div>
            </div>
            <!-- END About Tab -->



            <!-- BEGIN Share Tab -->
            <div class="tab-pane" id="share">
                <h4><?=Language::getText('share')?></h4>
                <div class="panel panel-default">
                    <div class="panel-body row">

                        <div class="col-xs-4">
                            <!--
                            Share Widget Notes
                             - Please replace <your_app_id> in the FaceBook share URL with your actual app id obtained from FaceBook's website. This widget will not work until that happens.
                             - FaceBook, and Google + widgets require the video's URL to be publicly accessible, otherwise the widgets will not work.
                            -->
                            <!-- FACEBOOK BUTTON -->
                            <meta property="og:url" content="<?=$this->getService('Video')->getUrl($video)?>/" />
                            <meta property="og:title" content="<?=$video->title?>" />
                            <meta property="og:description" content="<?=$video->description?>" />
                            <meta property="og:image" content="<?=$config->thumbUrl?>/<?=$video->filename?>.jpg" />
                            <meta property="og:type" content="video" />
                            <meta property="og:video" content="<?=$config->h264Url?>/<?=$video->filename?>.mp4">
                            <meta property="og:video:type" content="video/mp4">
                            <meta property="og:video:width" content="640">
                            <meta property="og:video:height" content="360">
                            <script>if (window.location.hash === '#facebook-share') {window.close();}</script>
                            <a class="facebook" href="https://www.facebook.com/dialog/share?app_id=<your_app_id>&display=popup&href=<?=urlencode($this->getService('Video')->getUrl($video) . '/')?>&redirect_uri=<?=urlencode($this->getService('Video')->getUrl($video) . '/#facebook-share')?>" onClick="window.open(this.href, 'sharewindow','width=550,height=300');return false;">Share on Facebook</a>

                            <!-- TWITTER BUTTON -->
                            <a class="twitter" href="" onClick="window.open('https://twitter.com/share?url=<?=urlencode($this->getService('Video')->getUrl($video) . '/')?>&text=<?=urlencode(Functions::cutOff($video->description, 140))?>','sharewindow','width=650,height=400');return false;">Share on Twitter</a>

                            <!-- Google +BUTTON -->
                            <a class="google" href="https://plus.google.com/share?url=<?=urlencode($this->getService('Video')->getUrl($video) . '/')?>" onClick="javascript:window.open(this.href, 'sharewindow', 'height=600,width=600');return false;">Share</a>
                        </div>

                        <?php if ($video->disableEmbed == '0' && $video->gated == '0'): ?>
                            <!-- EMBED CODE -->
                            <div class="col-xs-8">
                                <p class="h4"><?=Language::getText('embed')?></p>
                                <p><?=Language::getText('embed_text')?></p>
                                <textarea class="form-control" rows="5" cols="58">&lt;iframe src="<?=BASE_URL?>/embed/<?=$video->videoId?>/" width="480" height="360" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</textarea>
                            </div>
                        <?php endif; ?>

                    </div>
                </div>
            </div>
            <!-- END Share Tab -->



            <!-- BEGIN Add Tab -->
            <div class="tab-pane" id="add-to-playlist">


                <h4><?=Language::getText('add_to')?></h4>
                <div class="panel panel-default">
                    <div class="panel-body">

                        <?php if ($loggedInUser): ?>

                            <div class="test col-xs-12 col-sm-5">
                                <div class="scrollbar-outer playlist-container" >
                                    <ul>
                                        <?php $playlistService = $this->getService('Playlist'); ?>
                                        <li class="<?php echo $playlistService->checkListing($video, $favoritesList) ? 'added' : ''; ?>">
                                            <i class="glyphicon glyphicon-ok-sign"></i>
                                            <i class="glyphicon glyphicon-plus-sign"></i>
                                            <a
                                                data-playlist_id="<?=$favoritesList->playlistId?>"
                                                href=""
                                                data-video="<?php echo $video->videoId; ?>"
                                            ><?=Language::getText('favorites')?></a>
                                        </li>
                                        <li class="<?php echo $playlistService->checkListing($video, $watchLaterList) ? 'added' : ''; ?>">
                                            <i class="glyphicon glyphicon-ok-sign"></i>
                                            <i class="glyphicon glyphicon-plus-sign"></i>
                                            <a
                                                data-playlist_id="<?=$watchLaterList->playlistId?>"
                                                href=""
                                                data-video="<?php echo $video->videoId; ?>"
                                            ><?=Language::getText('watch_later')?></a>
                                        </li>
                                        <?php if (count($userPlaylists) > 0): ?>
                                            <li><strong><?=Language::getText('playlists')?></strong></li>
                                            <?php foreach ($userPlaylists as $userPlaylist): ?>
                                                <li class="<?php echo $playlistService->checkListing($video, $userPlaylist) ? 'added' : ''; ?>">
                                                    <i class="glyphicon glyphicon-ok-sign"></i>
                                                    <i class="glyphicon glyphicon-plus-sign"></i>
                                                    <a
                                                        data-playlist_id="<?=$userPlaylist->playlistId?>"
                                                        href=""
                                                        data-video="<?php echo $video->videoId; ?>"
                                                    ><?=$userPlaylist->name?> (<?=count($userPlaylist->entries)?>)</a>
                                                </li>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                    </ul>
                                </div>
                            </div>

                            <div class="col-xs-12 col-sm-5 col-sm-offset-2">
                                <p class="h4"><?=Language::getText('create_new_playlist')?></p>
                                <form>
                                    <div class="form-group">
                                        <label class="control-label"><?=Language::getText('playlist_name')?>:</label>
                                        <input class="form-control" type="text" name="playlist_name" />
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label"><?=Language::getText('visibility')?>:</label>
                                        <select class="form-control" name="playlist_visibility">
                                            <option value="public"><?=Language::getText('public')?></option>
                                            <option value="private"><?=Language::getText('private')?></option>
                                        </select>
                                    </div>
                                    <input type="hidden" name="action" value="create" />
                                    <input type="hidden" name="video_id" value="<?=$video->videoId?>" />
                                    <input class="btn btn-primary" type="submit" value="<?=Language::getText('create_playlist_button')?>" />
                                </form>
                            </div>

                        <?php else: ?>
                            <?=Language::getText('playlist_login', array('url' => BASE_URL . '/login/?redirect=' . urlencode($this->getService('Video')->getUrl($video))))?>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
            <!-- END Add Tab -->

        </div>
        <!-- END Tab Panes -->



        <!-- BEGIN Comments Header -->
        <div class="row" id="comments-header">
            <h4 class="col-xs-6">
                <?=Language::getText('comments_header')?>
                <?=($video->commentsClosed) ? '' : ' (<span class="comment-total">' . $commentCount . '</span>)'?>
            </h4>
            <?php if (!$loggedInUser && $config->enableRegistrations): ?>
                <p class="col-xs-6 text-right"><?=Language::getText('comments_login_register', array('login_link' => BASE_URL . '/login/?redirect=' . urlencode($this->getService('Video')->getUrl($video)), 'register_link' => BASE_URL . '/register/'))?></p>
            <?php elseif (!$loggedInUser && !$config->enableRegistrations): ?>
                <p class="col-xs-6 text-right"><?=Language::getText('comments_login', array('login_link' => BASE_URL . '/login/?redirect=' . urlencode($this->getService('Video')->getUrl($video))))?></p>
            <?php endif; ?>
        </div>
        <!-- END Comments Header -->



        <!-- BEGIN Comments Container -->
        <div id="comments" class="panel panel-default">

            <div class="panel-body">

                <?php if ($video->commentsClosed): ?>
                    <?=Language::getText('comments_closed')?>
                <?php else: ?>

                    <?php if ($loggedInUser): ?>

                        <!-- BEGIN Comments Form -->
                        <div class="collapsed comment-form comment-form-main row">
                            <form action="" method="post">

                                <div class="col-xs-12 collapsed-show">
                                    <textarea class="form-control" rows="2" cols="50" name="comments" placeholder="<?=Language::getText('comments_button')?>"></textarea>
                                </div>

                                <div class="col-xs-12 collapsed-hide">
                                    <textarea class="form-control" rows="4" cols="50" name="comments" placeholder="<?=Language::getText('comments')?>"></textarea>
                                </div>

                                <div class="col-xs-6 col-sm-3 collapsed-hide">
                                    <a class="cancel" href=""><?=Language::getText('cancel')?></a>
                                </div>

                                <div class="col-xs-6 col-sm-3 col-sm-offset-6 text-right collapsed-hide">
                                    <input type="hidden" name="videoId" value="<?=$video->videoId?>" />
                                    <input type="hidden" name="parentCommentId" value="" />
                                    <input class="btn btn-primary" type="submit" name="button" value="<?=Language::getText('comments_button')?>" />
                                </div>

                            </form>
                        </div>
                        <!-- END Comments Form -->

                    <?php endif; ?>



                    <!-- BEGIN Comments List -->
                    <div class="comment-list">
                        <?php if ($commentCount > 0): ?>

                            <?php foreach ($commentCardList as $commentCard): ?>

                                <?php $commentIndentClass = getCommentIndentClass($commentCard->comment); ?>

                                <div class="media comment <?=$commentIndentClass?>" data-comment="<?=$commentCard->comment->commentId?>">
                                    <div class="media-left">
                                        <img class="media-object" width="60" height="60" src="<?=($commentCard->avatar) ? $commentCard->avatar : $this->options->themeUrl . '/images/avatar.gif'?>" />
                                    </div>
                                    <div class="media-body row">

                                        <div class="col-xs-8">
                                            <a href="<?=getUserProfileLink($commentCard->author)?>" class="comment-author"><?=$commentCard->author->username?></a>
                                            <span class="comment-date"><?=date('m/d/Y', strtotime($commentCard->comment->dateCreated))?></span>
                                            <?php if ($commentCard->comment->parentId != 0): ?>
                                                <span class="comment-reply"><?=Language::getText('reply_to')?>
                                                    <a class="comment-parent-author" href="<?=getUserProfileLink($commentCard->parentAuthor)?>"><?=$commentCard->parentAuthor->username?></a>
                                                </span>
                                            <?php endif; ?>
                                        </div>

                                        <div class="col-xs-4 comment-action text-right">
                                            <a class="reply" href=""><?=Language::getText('reply')?></a>
                                            <a class="flag" data-type="comment" data-id="<?=$commentCard->comment->commentId?>" href=""><?=Language::getText('report_abuse')?></a>
                                        </div>

                                        <p class="col-xs-12 comment-text"><?=nl2br($commentCard->comment->comments)?></p>
                                    </div>
                                </div>

                            <?php endforeach; ?>
                        <?php else: ?>
                            <p class="no-comments"><?=Language::getText('no_comments')?></p>
                        <?php endif; ?>
                    </div>
                    <!-- END Comments List -->

                <?php endif; ?>

            </div>

            <?php if ($commentCount > 5): ?>
                <div class="panel-footer text-center load-more">
                    <button
                        class="btn btn-primary load-more-btn"
                        data-total="<?php echo $commentCount; ?>"
                        data-video="<?php echo $video->videoId; ?>"
                        data-loading-text="<?=Language::getText('loading')?>"
                    ><?=Language::getText('load_more')?></button>
                </div>
            <?php endif; ?>

        </div>
        <!-- END Comments Container -->

    </div>
    <!-- END PLAY LEFT -->



    <!-- BEGIN PLAY RIGHT -->
    <div class="col-md-4 play-right">

        <?php $this->Block ('ad300.phtml'); ?>


        <!-- BEGIN RELATED VIDEOS -->
        <div class="related-videos">
            <h4><?=Language::getText('suggestions_header')?></h4>
            <?php if (count($relatedVideos) > 0): ?>

                <div class="video-list">

                <?php $videoService = $this->getService('Video'); ?>
                <?php foreach ($relatedVideos as $relatedVideo): ?>

                    <div class="video video-medium media">
                        <div class="media-left thumbnail">
                            <a href="<?=$videoService->getUrl($relatedVideo)?>/" title="<?=$relatedVideo->title?>">
                                <span class="glyphicon glyphicon-play"></span>
                                <img class="media-object" width="140" height="78" src="<?=$config->thumbUrl?>/<?=$relatedVideo->filename?>.jpg" />
                            </a>
                        </div>
                        <div class="media-body">
                            <p class="media-heading"><a href="<?=$videoService->getUrl($relatedVideo)?>/" title="<?=$relatedVideo->title?>"><?=$relatedVideo->title?></a></p>
                            <div class="small">
                                <?=Language::getText('by')?>: <a href="<?=BASE_URL?>/members/<?=$relatedVideo->username?>/" title="<?=$relatedVideo->username?>"><?=$relatedVideo->username?></a>
                                <span class="duration"><span class="glyphicon glyphicon-time"></span> <?=$relatedVideo->duration?></span>
                            </div>
                        </div>
                    </div>

                <?php endforeach; ?>
                </div>

            <?php else: ?>
                    <strong><?=Language::getText('no_suggestions')?></strong>
            <?php endif; ?>
        </div>
        <!-- END RELATED VIDEOS -->


    </div>
    <!-- END PLAY RIGHT -->

</div>

This is the code for the plugin which I am not sure if I got right or not.

<script>
        <script src="https://www.example.com/tv/cc-content/themes/corporate/js/video.plugin.js">
        <link rel="stylesheet" href="https://www.example.com/tv/cc-content/themes/corporate/css/video-theatermode.css">
        <script src="https://www.example.com/tv/cc-content/themes/corporate/js/video.theatermode.js">
        
        var player = video-player-container('video-player');

         player.theaterToggle();
 
         player.on("theaterMode",function(){
           if(player.theaterToggle().isTheater()){
             //The 'Theater' is enabled
           }else {
            //The 'Theater' is disabled
           }
         });
         </script>

I am getting a video is not defined in the console of firefox. I am not sure about setting the variables for the video id either. I need to get this done asap for the site to go live.