views:

1493

answers:

4

I need this video to play automatically. It would be nice, this code can play videos from other sources like yahoo etc.. Is it also possible to use HTML5, instead of jquery?

+1  A: 

Look at the demos for FancyBox and ColorBox

Pablo
+4  A: 

The function or plugin you use to display the popup window will probably be different from what you are using to display the video. In this example I used the Overlay Plugin from jQuery Tools to display the modal then used swfobject to display the YouTube Flash Player. Alternatively, you could use an HTML5 video player with Flash fallback to display the video, but you would still need it to popup your modal first.

<a href="http://www.youtube.com/v/2cxqZiWyW3g&amp;hl=en_US&amp;fs=1&amp;autoplay=1"
    class="video-link">Video 1</a>
<a href="http://www.youtube.com/v/607RMNoJfl4&amp;hl=en_US&amp;fs=1&amp;autoplay=1"
    class="video-link">Video 2</a>

<div class="modal" id="video-modal">
    <div id="video-container" style="width: 425px; height: 344px;"></div>
</div>

<script language="javascript" type="text/javascript">

    $(function() {
        var videoModal = $('#video-modal').overlay({
            expose: {
                color: 'black',
                loadSpeed: 200,
                opacity: 0.85
            },
            closeOnClick: true,
            api: true
        });

        $('.video-link').click(function() {
            videoModal.load();

            var videoUrl = $(this).attr('href');
            var flashvars = {};
            var params = {
                allowFullScreen: "true",
                allowscriptaccess: "always"
            };
            var attributes = {};

            swfobject.embedSWF(videoUrl, 'video-container', '425', '344', '9.0.0', '', flashvars, params, attributes);

            return false;
        });
    });

</script>
DavGarcia
Thanks, DavGarcia! Do you know how to play the video automatically? This code only pop up the youtube video, but user has to click it to play.
WinFXGuy
DavGarcia
A: 

PrettyPhoto is a pure JavaScript library that displays images and videos in a lightbox.

For your purposes, you need you tag the YouTube link with a special "rel" attribute, the video will then open in a popup lightbox.

adib
@adib question is tagged with asp.net. So -1
piemesons
@piemesons - the author of PrettyPhoto also releases a pure JavaScript library, which can be used with asp.net -- so I still believe it's relevant.
adib
@adib then better you format your answer in that way.
piemesons
A: 

SimpleModal is a great jQuery plugin as it offers many different options, one being displaying external content:

// Display an external page using an iframe
var src = "http://365.ericmmartin.com/";
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
    closeHTML:"",
    containerCss:{
        backgroundColor:"#fff",
        borderColor:"#fff",
        height:450,
        padding:0,
        width:830
    },
    overlayClose:true
});

Bill Beckelman has great series of tutorials on integrating SimpleModal with Asp.Net as custom confirmation dialog box. He demonstrates how to create great client side functionality as well as how to post back to the server. it really helped get my head wrapped around how to best integrate jQuery with ASP.Net.

David Robbins