• 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

global variable for shortcode

Foliovision › Forums › FV Player › How to … › global variable for shortcode

  • tcnet 5 years, 4 months ago

    Hello!
    What would be the best way to utilize a global variable w/ FV Player?

    I have created global variable called $token

    It works and is available on my page, as I’ve been able to get it to print out the variable value on my page.

    How can I get that to be used at the end of a URL?

    If I add it in the FV Player database:
    https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4?token=$token

    It doesn’t work. You can see on the Streaming Server coming in as:
    https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4?token=

    Same goes if you try using the URL in the shortcode:
    [fvplayer src=https://mystreamingserver.com:443/live/whiteroom/playlist.m3u8?token=$token live='false']

    I see this on my streaming server.

    INFO server comment – Client connecting with id 590366983 and query string token=$token

    So the global variable doesn’t get called.

    Do you have a way to call a global variable directly in WordPress editor or in your shortcode editor?

    I have tried a 3rd party plugin, Woody Ad Snippets https://woodysnippet.com/

    and that does actually launch the FV Player with my global variable $token value added to the end of url .
    https://mystreamingserver.com:443/live/whiteroom/playlist.m3u8?token=5f66cc2b0fb30

    But I get some funky behavior from FV Player when launched this way.

    Here is what I get. First off, I am trying to play a Live feed from a Streaming Server (HLS).

    Here are my issues:
    A)
    If I use the shortcode config live=”true”, then when I click play, the the video plays and I can hear the audio, but the “buffer” icon keeps going, even though the video and audio is playing fine. If you hit the “rewind” video button, then it goes away.

    B) As a work around to the above, ,I switch it to live=”false, then when I click play, the the video plays and I can hear the audio, but the video progress bar scroll across the screen from left to right as progress bars go, but keeps going BEYOND the player itself, until it hits the very right side of the browser.

    If I put a regular FV Player via shortcode (but not launched through the snippets plugin) then they do not exhibit either of these issues.

    It’s not a buffering issues as it ONLY happens when launching the FV Player via shortcode inside of another plugin.

    But that is the ONLY way that I’ve been able to get access to my global variable that I have set.

    Here’s the code that I”m using in Woody Snippets that IS launching FV Player with my global variable $token populated with the value.

    global $token;
    echo “<p>”;
    echo do_shortcode(“[fvplayer src=https://mystreamingserver.com:443/live/whiteroom/playlist.m3u8?token={$token} live='false']“);

    Need some help, if you have any ideas to try?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • tcnet 5 years ago

    Hello,

    I’ve been working on this over the weekend. I am still not able to get it to work with FV Player, I get the issues described above. If I take another player (Bradmax) and use that instead, it works fine with no issues:

    global $token;
    echo $token;
    echo “<p>”;
    echo do_shortcode(“[fvplayer src='https://mystreamingserver.com:443/live/cyanroom/playlist.m3u8?token={$token}' live='true']“);
    echo do_shortcode(“[bradmax_video url=’https://mystreamingserver.com:443/live/cyanroom/playlist.m3u8?token={$token}’]”);

    Any assistance would be appreciated, as we were hoping to go live this Friday.

    Thanks!

    Martin 5 years ago

    Hello tcnet,

    the proper way of appending such argument to the video URL would be using the fv_flowplayer_video_src filter. You can look it up in FV Player Programmer’s Guide: https://foliovision.com/player/advanced/api-programming

    I doubt it will fix the issue you are having though.

    Please open your browser console (here’s how https://foliovision.com/player/troubleshooting/javascript-browser-console), then try to play that video again and see if any error appears in that console.

    How long does your token last? Can you send a URL we can test with?

    FV Player Pro also has a class in it to append such token to the video URL using Ajax, so that it can’t be parsed from page HTML code.

    Thanks,
    Martin

    tcnet 5 years ago

    My browser keeps crashing everytime I try to respond. Sorry for the late response.

    Why does it work fine w/ the Bradmax player?

    I did try bringing up the console and when I press play and get the weird buffering when playing the live fed but it didn’t show errors.

    <–
    the proper way of appending such argument to the video URL would be using the fv_flowplayer_video_src filter. You can look it up in FV Player Programmer’s Guide: https://foliovision.com/player/advanced/api-programming
    –>

    I will have to try to figure this out.

    What does $url show with this:
    $url = add_query_arg( ‘token’, ‘SAMPLETOKEN’, $url );

    (from your example).

    Thanks,
    David

    Our tokens last for a while but they are tied to an IP address, so you wouldn’t be able to test unless you gave me an ip address of the browser that would be testing.

    <–
    FV Player Pro also has a class in it to append such token to the video URL using Ajax, so that it can’t be parsed from page HTML code.
    –>

    I don’t know Ajax unfortunately.

    Martin 5 years ago

    Hello tcnet,

    I can test this with IP 172.105.78.177. So please generate a token for us and send over the full video URL.

    You can also try to run this on the browser console and send us the screenshot of the output (assuming it’s the only player on the page):

    JSON.stringify( flowplayer(0).conf.clip, true, 2 )

    In that sample code the $url is the argument of the filter function – the full video URL, starting with https:// and ending with the file extension.

    Thanks,
    Martin

Viewing 4 replies - 1 through 4 (of 4 total)
Reply To: global variable for shortcode



Please Sign in or Register to upload files.

Related Posts

  1. List of Shortcode Parameters

  2. Introducing FV Player’s New Shortcode Editor

  3. How to use RTMP streams with Flash – Deprecated

Primary Sidebar

How to …

    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‬