2016-07-05 21 views
1

我正在嘗試使用TypeScript在Ionic 2應用程序中捕獲視頻。拍照很簡單,看起來很簡單。如何在TypeScript中記錄Ionic 2應用程序中的視頻?

Camera.getPicture({ 
     destinationType: Camera.DestinationType.DATA_URL, 
     mediaType: Camera.MediaType.PICTURE, 
     targetHeight: 1000, 
     targetWidth: 1000 
    }).then((imageData) => { 
     this.base64Image = "data:image/jpeg;base64," + imageData; 
    }, (err) => { 
     console.log(err); 
    }); 
    } 

爲了捕捉視頻我需要做些什麼改變?

+0

[HTML 5視頻錄製和存儲流]的可能重複(http://stackoverflow.com/questions/18509385/html-5-video-recording-and-storing-a-stream) – str

回答

1

我沒有看看這個應用程序的代碼,但,但你可以看看那裏使用的插件以及它們是如何工作的(在nexus 7 2013上工作)。

https://github.com/rossmartin/video-editor-ionic2

這些都是需要的插件:

cordova-plugin-camera 
cordova-plugin-device 
cordova-plugin-media-capture 
https://github.com/driftyco/ionic-plugin-keyboard.git 
cordova-plugin-statusbar 
cordova-plugin-spinner-dialog 
cordova-plugin-instagram-assets-picker 
cordova-plugin-video-editor 
+0

我已經看到了這個回答另一個問題。我的問題是如何在沒有ngZone的打字稿應用程序中執行此操作? –

+0

你看過那個鏈接嗎?你寫了一些我們可以看看的代碼嗎? – sebaferreras

+0

我嘗試使用該代碼。它說屬性「設備」不存在於「導航器」類型中。 –

0

您必須安裝媒體捕獲插件ionic plugin add cordova-plugin-media-capture然後安裝角打字稿包裝npm install --save @ionic-native/media-capture

import { MediaCapture, MediaFile } from '@ionic-native/media-capture'; // import the angular typescript classes from the installed wrapper 

@Component(...) 

export class Test{ 
    constructor(private mediaCapture: MediaCapture) { } // inject the services in the constructor 

    this.mediaCapture.captureVideo().then((data: MediaFile[]) =>{ 
    console.log(data) // data is the captured video file object 
}); 
} 

檢查離子文件的這個插件https://ionicframework.com/docs/native/media-capture/

相關問題