Last active
March 8, 2017 14:17
-
-
Save pietromalerba/5509046 to your computer and use it in GitHub Desktop.
Titanium Record Video snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var btnCamera = Ti.UI.createButton({ | |
title: 'Record', | |
top: 500, | |
left: 910, | |
width: 100, | |
height: 100, | |
borderColor: "#FFF", | |
borderRadius: 50, | |
borderWidth: 3, | |
backgroundImage: 'none', | |
style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN , | |
color: "#FFF", | |
font: { | |
fontSize: 20, | |
fontFamily: 'Helvetica Neue' | |
}, | |
minimumFontSize: 8, | |
selectedColor: 'yellow', | |
textAlign: 'center', | |
backgroundGradient:{type:'linear', | |
colors:['#4D81DB','#000269'], | |
backFillStart:false} | |
}); | |
btnCamera.addEventListener('click', function (e) { | |
// | |
// Show the camera | |
// | |
Ti.Media.showCamera({ | |
inPopOver: true, // set this to true | |
popoverView: btnCamera, // "view" for the pointer arrow direction | |
autohide : false, | |
animated : false, | |
allowEditing: false, | |
success: function (event) { | |
var video = event.media; | |
movieFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'mymovie.mov'); | |
movieFile.write(video); | |
Ti.Media.hideCamera(); | |
var activeMovie = Titanium.Media.createVideoPlayer({ | |
backgroundColor:'#111', | |
mediaControlStyle:Titanium.Media.VIDEO_CONTROL_DEFAULT, | |
scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FILL, | |
//contentURL:movieFile.nativePath | |
media:movieFile // note you can use either contentURL to nativePath or the file object | |
}); | |
activeMovie.play(); | |
if (parseFloat(Titanium.Platform.version) >= 3.2) | |
{ | |
thiswin.add(activeMovie); | |
} | |
activeMovie.addEventListener('complete', function() | |
{ | |
movieFile.deleteFile(); | |
activeMovie.stop(); | |
thiswin.remove(activeMovie); | |
}); | |
}, | |
cancel: function (event) { | |
Titanium.Media.startVideoCapture(); | |
}, | |
error: function (error) { | |
alert('error'); | |
}, | |
mediaTypes: Titanium.Media.MEDIA_TYPE_VIDEO, | |
videoMaximumDuration:10000, | |
videoQuality:Titanium.Media.QUALITY_HIGH }); | |
// | |
// and start recording | |
// | |
Titanium.Media.startVideoCapture(); | |
}); | |
thiswin.add(btnCamera); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment