0

Is there a way for me to get the file url from this function without changing the javascript and without running the function?

  jwplayer('jsCmgPlayer').setup({
    flashplayer: 'http://website.com/player.swf',
    file: 'http://website.com/0015980.mp3',
    autostart: true,
 'skin': 'http://www.website.com/skin.xml',
 'controlbar': 'bottom',
    height: 28,
    width: 620
  });

I want to get http://website.com/0015980.mp3 as a separate variable.

4
  • 4
    Look at the plugin's docs and see if there is a method to get an option value. Maybe there's a method like getConfig or something. Commented Sep 13, 2012 at 15:08
  • 2
    That statement is running the function already. Commented Sep 13, 2012 at 15:12
  • 1
    By the way, you're calling setup yourself, so the value you provide as the url is coming from you. So you can do with it what you want. If you give us a little context code we can help you find the cleanest solution. Commented Sep 13, 2012 at 15:16
  • 1
    In your snippet, the value you want is assigned to a property of an object literal, which is passed as an argument. Why not var obj = {flashplayer:'http://',...};, basically everything between the curlies. Commented Sep 13, 2012 at 15:18

3 Answers 3

1

It's not possible. If you don't run the function you can't access the property over the plugins API because it's never set nor can you access it from an outer scope in your JavaScript code. The argument hash is not visible outside of this function.

Sign up to request clarification or add additional context in comments.

Comments

0

No. If the function is not run, the object containing the url can't be accessed. You only could try to get the function's source code as a string, and dig around in it e.g. with a regular expression to match that object literal.

Comments

0

The javascript you provide is running the function already. Since you are calling the setup code and you provide the arguments you can do this:

// create the arguments object
var setupArgs = {
    flashplayer: 'http://website.com/player.swf',
    file: 'http://website.com/0015980.mp3',
    autostart: true,
    'skin': 'http://www.website.com/skin.xml',
    'controlbar': 'bottom',
    height: 28,
    width: 620
}

// setup the plugin
jwplayer('jsCmgPlayer').setup(setupArgs);

Now you can use the arguments however you want, to access that url:

// use the arguments object for other things
setupArgs.file;

1 Comment

We do not know if he is actually providing the code. It could be a snippet from somewhere included on the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.