Code Monkey home page Code Monkey logo

tiscreenrecorder's Introduction

TiScreenRecorder

A simple Appcelerator Titanium module for iOS screen recording.


Usage

Example app.js

// TiScreenRecorder : example app. 
// @kosso : November 2016


// open a single window
var win = Ti.UI.createWindow({
	backgroundColor:'white'
});

var label = Ti.UI.createLabel({
	text: 'ready',
	backgroundColor: '#99ffffff',
	color: '#333',
	width: Ti.UI.SIZE,
	borderRadius: 6,
	bottom: 5,
	left: 5,
	zIndex: 10
});

win.add(label);

var screenrecorder = require('com.kosso.tiscreenrecorder');

var isRecording = false;


var btn_rec = Ti.UI.createButton({
	  title: ' o ',
	  width: 30,
	  bottom: 5,
	  zIndex: 10,
	  height: 30,
	  borderRadius: 15,
	  color: 'white',
	  tintColor: 'white',
	  textAlign: 'center',
	  backgroundColor: '#990000'
});



btn_rec.addEventListener('click', function(){

	if(isRecording){
		screenrecorder.stopRecording();
		label.text = 'stopped';
	  	setTimeout(function(){
	  		label.text = 'ready';
	  	}, 3000);

	} else {

		var d = new Date();
		var filename = 'recording_'+d.getTime()+'.mp4';
		var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);
		if ( file.exists() ) {
		     file.deleteFile();
		}
		var video_url = file.nativePath; // eg: file:///etc/etc...
		file = null;
		console.log('video_url : ', video_url);

			
	 	screenrecorder.startRecording(video_url);
	 	// To just automatically save the video to the Camera Roll, leave out the video url 
	 	// eg: screenrecorder.startRecording();

	 	label.text = 'recording';
		
	}
	isRecording = !isRecording;
});


screenrecorder.addEventListener('success', function(e){
	console.log('screen recording done! : ', e);
	// Saved video is at e.nativePath (if a video_url was set)

});

// Just something to record... 

var wv = Ti.UI.createWebView({
	url : 'http://www.bbc.co.uk/news',
	width: Ti.UI.FILL,
	height: Ti.UI.FILL,
	backgroundColor: '#eee',
	zIndex: 1
});

win.add(wv);
win.add(btn_rec);

win.open();

Ideas:

  • Hide recording button when starting. Add a shake gesture to stop recording.

  • Add audio recording.

  • Allow specifying an area of screen to record.

  • Generate a GIF ;)

  • Show location of touches.

    โ€‹


Credit :


Author : @kosso - November 2016

tiscreenrecorder's People

Contributors

kosso avatar

Watchers

James Cloos avatar

Forkers

creador

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.