• Skip to content
  • Skip to primary sidebar
  • Skip to footer

Foliovision

Main navigation

  • Weblog
    • FV Player
    • WordPress
    • Video of the Week
    • Case Studies
    • Business
  • About
    • Testimonials
    • Meet the Team
    • We Support
    • Careers
    • Contact
    • Pricing
  • Products
  • Support
    • FV Player Docs
    • Pro Support
  • Login
  • Basket is empty

FV Flowplayer Playlist search

Foliovision › Forums › FV Player › How to … › FV Flowplayer Playlist search

  • D.C. D. 11 months, 3 weeks ago

    Hi! So I have constructed a search field for my FV Flowplayer. It works as needed for everything EXCEPT – After searching for a video and then deleting the search term and clicking on a SELF-HOSTED video the controls don’t work and the loading animation is present whole time.

    I know this isn’t something you support – but I was hoping you might have a hint of what i should tell ChatGPT to look for to reapply the controls after we unload the search. — here’s a page with it on – https://dcdouglas.com/actor-film-television-videos-demo-reel/indie-film/ — a self hosted video is the Drowning in secrets.

    Here is the javascript:

    jQuery(document).ready(function($) {
        var flowPlayer = null; // Store the reference to the FlowPlayer instance
        var isPlaying = false; // Flag to prevent multiple click handling
        var controlsInitialized = false; // Flag to track if controls are initialized
    
        function destroyFlowPlayer() {
            if (flowPlayer) {
                try {
                    console.log('Destroying FlowPlayer', flowPlayer);
                    flowPlayer.unload();
                    flowPlayer = null;
                    console.log('FlowPlayer destroyed');
                } catch (error) {
                    console.error('Error destroying FlowPlayer:', error);
                }
            }
        }
    
        function initializeFlowPlayer() {
            return new Promise((resolve, reject) => {
                var checkInterval = setInterval(() => {
                    var player = $('.flowplayer').data('flowplayer');
                    if (player) {
                        flowPlayer = player;
                        clearInterval(checkInterval);
                        console.log('FlowPlayer initialized', player);
                        console.log('FlowPlayer config', player.conf);
                        resolve(flowPlayer);
                    }
                }, 500);
            });
        }
    
        function reinitializeSelfHostedVideo(player) {
            if (!controlsInitialized && player.video && player.video.sources[0].type === 'video/mp4') {
                // Explicitly reinitialize controls for self-hosted videos
                player.ui.createSubtitleControl();
                player.ui.setActiveSubtitleItem();
                controlsInitialized = true;
                console.log('Self-hosted video controls reinitialized');
            }
        }
    
        function attachControlListeners(player) {
            player.on('pause', function() {
                console.log('Video paused');
            });
            player.on('mute', function() {
                console.log('Video muted');
            });
            player.on('resume', function() {
                console.log('Video resumed');
            });
            player.on('unmute', function() {
                console.log('Video unmuted');
            });
            player.on('ready', function() {
                console.log('Video ready');
                reinitializeSelfHostedVideo(player); // Reinitialize controls for self-hosted videos
            });
            player.on('unload', function() {
                console.log('Video unloaded');
            });
            player.on('finish', function() {
                console.log('Video finished');
            });
        }
    
        function unloadCurrentVideo(player) {
            return new Promise((resolve, reject) => {
                console.log('Unloading current video');
                try {
                    player.unload();
                    console.log('Current video unloaded');
                    resolve();
                } catch (error) {
                    console.error('Error unloading video:', error);
                    reject(error);
                }
            });
        }
    
        function playVideo(videoId) {
            if (isPlaying) return; // Prevent multiple clicks
    
            isPlaying = true; // Set the flag to true
            console.log('Preparing to play video ID:', videoId);
    
            initializeFlowPlayer().then(player => {
                if (player && typeof player.play === 'function') {
                    var playlist = player.conf.playlist || [];
                    var videoIndex = playlist.findIndex(video => video.id == videoId);
    
                    if (videoIndex !== -1) {
                        unloadCurrentVideo(player).then(() => {
                            console.log('Playing video at index:', videoIndex);
                            player.play(videoIndex);
                            attachControlListeners(player); // Ensure controls are attached
                            isPlaying = false; // Reset the flag after playing
                        }).catch((error) => {
                            console.error('Error unloading video:', error);
                            isPlaying = false; // Reset the flag if error
                        });
                    } else {
                        console.error('Video ID not found in FlowPlayer playlist');
                        isPlaying = false; // Reset the flag if error
                    }
                } else {
                    console.error('FlowPlayer instance not found or play method not available');
                    isPlaying = false; // Reset the flag if error
                }
            }).catch((error) => {
                console.error('Error initializing FlowPlayer:', error);
                isPlaying = false; // Reset the flag if error
            });
        }
    
        function updatePlaylist(query) {
            var $playlist = $('.fv-playlist-slider-wrapper .fp-playlist-external a');
    
            if (query === "") {
                $playlist.show();
            } else {
                $playlist.each(function() {
                    var $this = $(this);
                    var title = $this.find('h4 span').text().toLowerCase();
    
                    if (title.includes(query)) {
                        $this.show();
                    } else {
                        $this.hide();
                    }
                });
            }
    
            // Scroll the playlist container back to the beginning
            $('.fv-playlist-slider-wrapper').scrollLeft(0);
        }
    
        $('#video-search').on('input', function() {
            var query = $(this).val().toLowerCase();
            updatePlaylist(query);
    
            if (flowplayer) {
                reinitializeSelfHostedVideo(flowplayer); // Reinitialize controls for self-hosted videos
            }
        });
    
        $('.fv-playlist-slider-wrapper .fp-playlist-external a').off('click').on('click', function(e) {
            e.preventDefault();
            e.stopImmediatePropagation(); // Prevent any additional handlers from being triggered
    
            var clickedItem = $(this);
            var videoId = clickedItem.data('item').id;
    
            console.log('First click on playlist');
            console.log('Clicked video ID:', videoId);
    
            // Ensure only one click is processed
            if (!isPlaying) {
                playVideo(videoId);
            } else {
                console.log('Already processing a video click');
            }
        });
    
        // Initial initialization of FlowPlayer
        initializeFlowPlayer().then(player => {
            if (player && typeof player.play === 'function') {
                attachControlListeners(player);
            }
        }).catch((error) => {
            console.error('Error initializing FlowPlayer on document ready:', error);
        });
    });

    And the PHP

    <?php
    
    // Enqueue necessary scripts
    function custom_video_search_enqueue_scripts() {
        wp_enqueue_script('custom-video-search', plugin_dir_url(__FILE__) . 'custom-video-search.js', array('jquery'), null, true);
    }
    add_action('wp_enqueue_scripts', 'custom_video_search_enqueue_scripts');
    
    // Create the shortcode
    function custom_video_search_shortcode($atts) {
        ob_start();
        ?>
        <div class="custom-video-search">
            <input type="text" id="video-search" placeholder="Search videos...">
        </div>
        <?php
        return ob_get_clean();
    }
    add_shortcode('video_search', 'custom_video_search_shortcode');
    
    // Ensure no whitespace is outputted before the XML declaration
    function custom_video_search_init() {
        ob_start(); // Start output buffering
    }
    add_action('init', 'custom_video_search_init');
    
    function custom_video_search_shutdown() {
        ob_end_flush(); // End output buffering and flush the output
    }
    add_action('shutdown', 'custom_video_search_shutdown');
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • D.C. D. 12 months ago

    After further testing, it appears that if I play a Youtube video first and then play a self-hosted video, the controls are non-clickable and they remain and the loading animation stays. The only thing to do is watch video or click away.

    Martin 12 months ago

    Hello D.C.,

    I’m checking with Alec if we would like to have a playlist search function right in core FV Player.

    Please test the issue with YouTube and MP4 videos (I guess you are self-hosting an MP4 video) in playlist without the search function. I was not able to run into a loading issue with such combination of videos in playlist.

    However I did notice that when I play the YouTube video after MP4 it plays without sound and I need to tap again for it to became audible.

    Thanks,
    Martin

    Alec Kinnear 12 months ago
    Avatar photo

    Hi DC,

    Love your acting showreel page. That search works great!

    We’re thinking hard about adding playlist search. If we did, it would just be an extra shortcode to put wherever you want on the page [fvplaylistsearch].

    Making the web work for you, Alec

Viewing 3 replies - 1 through 3 (of 3 total)
Reply To: FV Flowplayer Playlist search



Please Sign in or Register to upload files.

Related Posts

  1. adjust playlist font size on mobile

    adjust playlist font size on mobile

  2. YouTube/self-hosted mixed playlist

    YouTube/self-hosted mixed playlist

  3. YouTube playlist glitch

    YouTube playlist glitch

Primary Sidebar

Sign in Register
FV Player Docs Post New Topic

Welcome

to Foliovision support forums! We'll be happy to provide free support to resolve all the reported bugs. You always can start by specifying your OS and browser and steps to reproduce the bug.

If you need help with the installation on your site, please submit a request for a Pro Support Incident. We'll have you up and running in no time, with detailed instructions on how to resolve your issue yourself in the future.

Facing a hard to solve WordPress problem? On a tight deadline?

Let us take care of it for you
right now.

Pro Support Buy FV Player

Footer

Our Plugins

  • FV WordPress Flowplayer
  • FV Thoughtful Comments
  • FV Simpler SEO
  • FV Antispam
  • FV Gravatar Cache
  • FV Testimonials

Free Tools

  • Pandoc Online
  • Article spinner
  • WordPress Password Finder
  • Delete LinkedIn Account
  • Responsive Design Calculator
Foliovision logo
All materials © 2025 Foliovision s.r.o. | Panská 12 - 81101 Bratislava - Slovakia | info@foliovision.com
  • This Site Uses Cookies
  • Privacy Policy
  • Terms of Service
  • Site Map
  • Contact
  • Tel. ‭+421 2/5292 0086‬

We are using cookies to give you the best experience on our website.

You can find out more about which cookies we are using or switch them off in .

Powered by  GDPR Cookie Compliance
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Necessary Cookies

Strictly Necessary Cookie allow you to log in and download your software or post to forums.

We use the WordPress login cookie and the session cookie.

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.

Support Cookies

Foliovision.com uses self-hosted Rocket.chat and self-hosted Freescout support desk to provide support for FV Player users. These cookies allow our visitors to chat with us and/or submit support tickets.

We are delighted to recommend self-hosted Rocket.chat and especially Freescout to other privacy-conscious independent publishers who would prefer to self-host support.

Please enable Strictly Necessary Cookies first so that we can save your preferences!

3rd Party Cookies

This website uses Google Analytics and Statcounter to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping this cookie enabled helps us to improve our website.

We reluctantly use Google Analytics as it helps us to test FV Player against popular Google Analytics features. Feel free to turn off these cookies if they make you feel uncomfortable.

Statcounter is an independent Irish stats service which we have been using since the beginning of recorded time, sixteen years ago.

Please enable Strictly Necessary Cookies first so that we can save your preferences!