• 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

global variable for shortcode

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

  • tcnet 4 years, 7 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

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!