1

How to dispaly the following code in drupal 7 module

 <script type="text/javascript" src="http://dubturbo1.counselstime.com/jwplayer/jwplayer.js"></script>
    <script>jwplayer.key="76oyax0SAVqgDM580AJ3+K23kIuN8HFkgahYRQ=="</script>
    <div id="my-video"></div>
    <script type="text/javascript">
        jwplayer('my-video').setup({
            file: 'http://192.168.1.150/sathya/video_test_512kb.mp4',
            width: '500',
            height: '300',
    controls: 'false',
    autostart: 'true',
    });
    </script>

1 Answer 1

1

You would need to add it to a JS file, either within your module (if necessary) or otherwise just put it within your themes JS file if you don't need a module for what you are doing.

Wrap it in a Drupal behaviours wrapper:

(function($) {

    Drupal.behaviors.setupVideo = {
        attach: function (context) {

          wplayer('my-video').setup({
            file: 'http://192.168.1.150/sathya/video_test_512kb.mp4',
            width: '500',
            height: '300',
            controls: 'false',
            autostart: 'true'
          });

        }
    };

})(jQuery);

You will also need to add the first JS file (the jwplayer stuff) in there too. Add it as a line in your theme or add it to your module:

drupal_add_js(drupal_get_path('module', 'MY_MODULE') . '/js/jwplayer.js', 'file');
Sign up to request clarification or add additional context in comments.

1 Comment

No problem! I +1'd you so you should now have enough rep to upvote and accept the answer :D

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.