locked
How to set src in Video using video from File Picker RRS feed

  • Question

  • Hi all,

    I am using Metro app.  I have a file picker to get a video from Video Library, I can get the video path, but when I try to put the path on src option, but when I try to play the video, I am getting an error. I can not find syntax how to use video library.

    I do not know what is wrong with this code:

            var Pickers = Windows.Storage.Pickers;
            var picker = Pickers.FileOpenPicker();
    
            picker.fileTypeFilter.append(".mp4", ".wmv");
            picker.viewMode = Pickers.PickerViewMode.thumbnail;
            picker.suggestedStartLocation = Pickers.PickerLocationId.videosLibrary;
    
            picker.pickSingleFileAsync().then(function (satu) {
                if (satu != null) {
                    var singlePlayVideo = document.getElementById("singlePlayVideo");
                    var judul = document.getElementById("judul");                     // test to display path on page
                    judul.textContent = satu.path;                                          // problem with F5 - Run in Debug Terminated
                    var url = URL.createObjectURL(text);
                    singlePlayVideo.innerHTML = "<source src='" + url + "'/>";              // this is not working
                    //singlePlayVideo.innerHTML = "<source satu.path='" + satu.path + "'/>";      // this is also not working
                }
            });

    Here my html page code:

            <section aria-label="Main content" role="main">
                <div>
                    <video id="singlePlayVideo" controls="controls" width="800" height="450">
                    </video>
                </div>
                <label id="judul"></label>
                <div id="listViewDiv" class="mediumImageTemplatizedListView">
                </div>
            </section>

    Please help me


    Jannen Siahaan - Indonesia



    • Edited by humaNiT Sunday, May 13, 2012 3:21 PM
    Sunday, May 13, 2012 3:15 PM

Answers

  • Try this:

    picker.pickSingleFileAsync().then(function (satu) {
                if (satu != null) {
                    var singlePlayVideo = document.getElementById("singlePlayVideo");                                         
                    singlePlayVideo.src =  URL.createObjectURL(satu, false); 
    singlePlayVideo.play();
                }
            });



    • Edited by jrboddie Sunday, May 13, 2012 3:51 PM
    • Marked as answer by humaNiT Sunday, May 13, 2012 4:24 PM
    Sunday, May 13, 2012 3:45 PM

All replies

  • Try this:

    picker.pickSingleFileAsync().then(function (satu) {
                if (satu != null) {
                    var singlePlayVideo = document.getElementById("singlePlayVideo");                                         
                    singlePlayVideo.src =  URL.createObjectURL(satu, false); 
    singlePlayVideo.play();
                }
            });



    • Edited by jrboddie Sunday, May 13, 2012 3:51 PM
    • Marked as answer by humaNiT Sunday, May 13, 2012 4:24 PM
    Sunday, May 13, 2012 3:45 PM
  • Thank you soo much, it works

    Jannen Siahaan - Indonesia

    Sunday, May 13, 2012 4:24 PM
  • Try this:

    picker.pickSingleFileAsync().then(function (satu) {
                if (satu != null) {
                    var singlePlayVideo = document.getElementById("singlePlayVideo");                                         
                    singlePlayVideo.src =  URL.createObjectURL(satu, false); 
    singlePlayVideo.play();
                }
            });



    Oh my god you just saved my life. I've been pulling my hair out.
    Wednesday, November 28, 2012 3:07 AM