1

I am opening a video file using input type file. Following is the function that is being called and file is being sent here.

function fetchVideo(file) {
    if(file) {
        var reader = new FileReader();
        reader.onload = function(e) {
            layoutVM.video = e.target.result;             
        }
        reader.readAsDataURL(file);
    }
}

The html for this is

<video loop muted autoplay>
     <source ng-src="{{layoutVM.video}}" type="video/mp4">
</video>

After FileReader works, e.target.result gets a long string starting from "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACA .................................. "

The video is not being loaded in source, any idea?

1 Answer 1

0

haven't tested though but can you try to create object URL from file instead of using reader?

function fetchVideo(file) {
    if(file) {
        layoutVM.video = URL.createObjectURL(file);             
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

oh, that's a pain. can you also try to add layoutVM.$apply();? stackoverflow.com/questions/18754943/…

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.