locked
Use a variable as a source?? RRS feed

  • Question

  • I have a variable URL

    But I want to use the data from url for my source to play a video

    <class="player" width="200" height="200" src=<NEED HELP HERE> </iframe>

    This doesn't work ---- <class="player" width="200" height="200" src=url </iframe>

    Normally I have a URL pointing to my video file, but now I want to use the URL inside url variable

    How do I do this?

    Thanks!


    • Edited by RandomXT Saturday, January 21, 2012 6:23 PM changed
    Saturday, January 21, 2012 5:21 AM

Answers

  • Hi R,

    Are am not 100% sure I follow what you are asking.  Are you saying you have a variable in your JavaScript code like var myVideoUrl =
    "http://somesite.com/myvideo.mp4"

     If so, you can do this in your JavaScript code:

     

    var myVideoUrl = "http://video.ch9.ms/build/2011/key01/BUILD2011KeynoteDay1_low_ch9.mp4";
            var video = document.getElementById('myvideo');
            video.src = myVideoUrl;
            video.autoplay=true;
    

     

    -Jeff


    Jeff Sanders (MSFT)
    Monday, January 23, 2012 4:17 PM
    Moderator