Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <div class="btn btn-info btn-raised">
  2. Subir Foto
  3. <input id="custom-input" type="file" (change)="fileChangeListener($event)" accept="video/*">
  4. </div>
  5.  
  6. <video controls>
  7. <source src="{{ data.video }}" type="{{ data.type }}">
  8. </video>
  9.  
  10. private fileChangeListener($event) {
  11. let fileList: FileList = $event.target.files;
  12. this.data = {};
  13. if (fileList.length > 0) {
  14. let file: File = fileList[0];
  15. console.log('video seleccionado', file);
  16. let myReader: FileReader = new FileReader();
  17. let that = this;
  18. myReader.onloadend = (loadEvent: any) => {
  19. console.log('video', myReader.result);
  20. this.data.video = myReader.result;
  21. this.data.type = file.type;
  22. };
  23. myReader.readAsDataURL(file);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement