how to use a custom wordpress player on your blog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    I have to go potty
    • Aug 2002
    • 55797

    #1

    how to use a custom wordpress player on your blog

    Some of you use the default flash player (JW FLASH PLAYER)

    Some people have asked me a simple way to use a custom based flash player without pasting the embed codes everytime.

    This is an easy and quick hack to play a .flv file with a custom field and a flash player.

    Here is an example of my flash player, your variables will be different, so check the documentation or the developer for which ones suit your custom player.

    This will needed to be added to header.php

    Code:
    <script type="text/javascript" src="<? bloginfo('template_directory'); ?>/swfobject.js"></script>
    This is based on you making a custom field called "video" and in that field you provide the direct url to the video. (a lot of sponsors will let you hotlink)

    this you would add to functions.php in your theme directory

    Code:
    function playvideo() {
    
    global $post;
    $player = get_bloginfo('template_directory').'/player.swf'; // location of my player
    $video = get_post_meta($post->ID, 'video', true);
    $width = '350';
    $height = '290';
    
    if ($video == true) {
            print '<span id="video-'.$post->ID.'" class="flashvideo"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</span>';
            print '<script type="text/javascript">
            var so = new SWFObject("'.$player.'","n-'.$post->ID.'","'.$width.'","'.$height.'","7");
            so.addParam("allowFullScreen", "true");
            so.addVariable("MediaLink", "'.$video.'");
            so.addVariable("playOnStart", "true");
            so.addVariable("autoDetectMedia", "true");
            so.addVariable("startVolume", "60");
            so.addVariable("showPlayButton", "true");
            so.addVariable("fitToPlayer", "true");
            so.addVariable("imageScaleType", "1");
            so.addVariable("loopMedia", "false");
            so.write("video-'.$post->ID.'");
            </script>';
    }
    
    }

    And finally how to add it to your theme.

    Find

    Code:
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    Add below it

    Code:
    <?php playvideo();?>
    It will only play a video if you set a url fo the video in the post, otherwise it will be ignored.

    Enjoy.
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


    My Newest Theme
  • Jdoughs
    Confirmed User
    • Mar 2004
    • 5794

    #2
    Very nice, mint post.
    LinkSpun - Premier Adult Link Trading Community - ICQ - 464/\281/\250
    Be Seen By New Webmasters/Affiliates * Target out webmasters/affiliates based on niches your sites are for less than $20 a month.
    AmeriNOC - Proudly hosted @ AmeriNOC!

    Comment

    • nolongerexists
      Confirmed User
      • Apr 2003
      • 1096

      #3
      anywhere to see it in action?
      work smart not hard ;)

      Comment

      • Itchy
        Datetronix.com
        • Jan 2001
        • 6525

        #4
        Very nice tip


        ICQ: 2588560
        Skype: Pornocop

        Comment

        • Fat Panda
          Porn is Dead. Move along.
          • Aug 2006
          • 13296

          #5
          very nice tip !!!!!!!

          Comment

          • Fat Panda
            Porn is Dead. Move along.
            • Aug 2006
            • 13296

            #6
            Btw. Thanks for all the great wordpress related posts Fris!

            Comment

            • fris
              I have to go potty
              • Aug 2002
              • 55797

              #7
              Originally posted by blindzior
              anywhere to see it in action?
              http://www.ajaxfood.com/?p=1
              Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


              My Newest Theme

              Comment

              • tranza
                ICQ: 197-556-237
                • Jun 2003
                • 57559

                #8
                It's helpful!
                I'm just a newbie.

                Comment

                • Click Obey
                  Confirmed User
                  • Jan 2007
                  • 196

                  #9
                  Fris, you have been making some kick ass posts lately. thanks!
                  Convert your clicks with Swank Dollars ICQ - 472 856 761

                  Comment

                  Working...