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

Foliovision

  • 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

dynamic linking to video time position

[Solved]

Foliovision › Forums › FV Player Pay Per View › Requests and Feedback › dynamic linking to video time position

  • meir kalmis 8 months, 1 week ago

    bsd
    i need to have a dynamic url created by a plugin that add to the url the time to be played.
    but i see in the link there is a ID like this:
    https://meirtv.com/shiurim/350752/#fvp_1085427345,7m00s
    I dont know how this 1085427345 id is generated, but as i have only one video per page, it would be good to ma ke something like:
    https://meirtv.com/shiurim/350752/&time=7m00s
    to work…
    any solutions?

Viewing 10 replies - 1 through 10 (of 10 total)
  • meir kalmis 8 months ago

    any ideas?

    meir kalmis 8 months ago

    still waiting

    meir kalmis 8 months ago

    still waiting…

    Martin 8 months ago

    Hello Meir,

    Since you are not using the FV Player database, 1085427345 is the video file name without the extension.

    I see that if FV Player could simply take the first player on the page and play it at a given timestamp it would be an easier solution.

    However in that case it would need extra logic to skip the video ad and also to be able to target individual videos in the playlists.

    Please let us know if that makes sense.

    It seems it would be also harder to keep track of what video you are really trying to link to at that timestamp. Please let us know about the exact use case for these links.

    Thanks,
    Martin

    meir kalmis 8 months ago

    i developed a chatbot ai, that answer questions and give links to specific position in videos..
    so the link is generated dynamicly , and has to has the specific time to go to the specific citation time in the video

    meir kalmis 8 months ago

    also this link do not go to playlist but to a unique video

    Martin 8 months ago

    Hello Meir,

    Thank you for the details.

    We need some time before we decide what’s the right thing to do for FV Player. Perhaps we would like these video links to target the first video on the page by default, but if we decide to do so we must stick to that behavior and not change our minds in the future.

    Thanks,
    Martin

    meir kalmis 8 months ago

    ok, i developed a solution by myself…
    the folowwing snippet seeks to timestamp for example:
    https://meirtv.com/shiurim/244997/?time=33m27s
    and if there is no “time” parameter, it will seek by fv player default (last watched etc)

    // FV Player Time Parameter Support (Updated)
    // Add this to your theme's functions.php or a code snippets plugin.
    
    // --- 1. Enqueue the JavaScript Handler ---
    // This script now only acts if a 'time' parameter is in the URL.
    function fvpt_enqueue_scripts() {
        // Only run this on single posts and pages where videos are likely to be.
        if (is_singular()) {
            $script = '
    jQuery(document).ready(function($) {
        // Get the time parameter directly from the page\'s URL.
        const urlParams = new URLSearchParams(window.location.search);
        const timeParam = urlParams.get("time");
    
        // CRITICAL FIX: Only run the seeking logic if a "time" parameter
        // actually exists in the URL. If it doesn\'t, this entire block is
        // skipped, allowing FV Player\'s default behavior (like "last watched") to work.
        if (timeParam) {
            // Function to parse time formats like "1h30m10s" or "90" into seconds.
            const parseTimeParam = (timeStr) => {
                if (!timeStr) return 0;
                let totalSeconds = 0;
                const regex = /(\d+)([hms])/g;
                let match;
                while ((match = regex.exec(timeStr)) !== null) {
                    const value = parseInt(match[1], 10);
                    const unit = match[2];
                    switch(unit) {
                        case "h": totalSeconds += value * 3600; break;
                        case "m": totalSeconds += value * 60; break;
                        case "s": totalSeconds += value; break;
                    }
                }
                // Fallback for plain seconds format (e.g., "?time=125")
                if (totalSeconds === 0 && /^\d+$/.test(timeStr)) {
                    totalSeconds = parseInt(timeStr, 10);
                }
                return totalSeconds;
            };
    
            const seekTime = parseTimeParam(timeParam);
    
            // Only seek if the time is greater than 0.
            if (seekTime > 0) {
                const applySeek = (api) => {
                    // The "ready" event ensures the video is loaded enough to seek.
                    api.on("ready", function() {
                        // This small timeout ensures our seek command runs after
                        // any initial player logic.
                        setTimeout(() => {
                            api.seek(seekTime);
                        }, 150);
                    });
                };
    
                // Hook into the FV Player API (supports V7+ and older versions).
                if (typeof flowplayer !== "undefined") {
                    flowplayer((api, root) => {
                        applySeek(api);
                    });
                } else if ($(".flowplayer").length) {
                    $(".flowplayer").each(function() {
                        const api = $(this).data("flowplayer");
                        if (api) {
                            applySeek(api);
                        }
                    });
                }
            }
        }
    });
            ';
            // Use wp_add_inline_script to safely add the JavaScript.
            wp_add_inline_script('jquery-core', $script);
        }
    }
    add_action('wp_enqueue_scripts', 'fvpt_enqueue_scripts');
    
    
    // --- 2. Add rewrite rule for pretty URLs (Optional) ---
    // This allows for URLs like /shiurim/123/time/1m30s/
    function fvpt_add_rewrite_rules() {
        add_rewrite_rule(
            '^shiurim/([0-9]+)/time/([0-9hms]+)/?$',
            'index.php?p=$matches[1]&time=$matches[2]', // We now use 'time' consistently.
            'top'
        );
    }
    add_action('init', 'fvpt_add_rewrite_rules');
    
    
    // --- 3. Shortcode to easily generate time-based links ---
    // Usage: [fv_time_link time="1m30s" text="Watch from 1:30"]
    function fvpt_time_link_shortcode($atts) {
        $atts = shortcode_atts(array(
            'time' => '0',
            'text' => 'Watch from here',
            'class' => 'fv-time-link'
        ), $atts, 'fv_time_link');
    
        // Use WordPress\'s add_query_arg to safely build the URL.
        $url = add_query_arg('time', esc_attr($atts['time']), get_permalink());
    
        return sprintf(
            '<a href="%s">%s</a>',
            esc_url($url),
            esc_attr($atts['class']),
            esc_html($atts['text'])
        );
    }
    add_shortcode('fv_time_link', 'fvpt_time_link_shortcode');
    
    
    // --- Helper function to get a time link programmatically ---
    function fvpt_get_time_link($time = '0m00s') {
        return add_query_arg('time', $time, get_permalink());
    }
    Martin 8 months ago

    Hello Meir,

    I checked your code and one issue which I see is the setTimeout call on ready. I wold be better if you could check for the first progress event instead as that one ensures the video actually started to play.

    I would suggest that you also check on mobile devices carefully.

    Thanks,
    Martin

    meir kalmis 8 months ago

    thanks…
    if something cames native in this feature please let me know

Viewing 10 replies - 1 through 10 (of 10 total)
Reply To: dynamic linking to video time position



Please Sign in or Register to upload files.

Related Posts

  1. after playing preroll, transcription widget doest work

    after playing preroll, transcription widget doest work

  2. Is FV Player`s elementor widget able to pull the custom dynamic video url?

    Is FV Player`s elementor widget able to pull the custom dynamic video url?

  3. Video Linking

Primary Sidebar

Requests and Feedback

    Categories

    • Business
    • Camera Reviews
    • Case Studies
    • Design
    • FV Player
    • Internet Marketing
    • IT
    • Life
    • SEO
    • Slovak
    • Video of the Week
    • WordPress

    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 © 2026 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‬