(
var f1, f2, f3, f4, f5, f6, f7,
width= 1280, height= 800,
window, movie, controls, button1, button2, button3, film, filmplay;

f1= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /2. Films/folhas 1.avi.ff.avi"; 
f2= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /2. Films/folhas 2.avi.ff.avi";
f3= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /2. Films/folhas 3.avi.ff.avi";
f4= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /2. Films/nuvens 1.avi.ff.avi";
f5= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /2. Films/nuvens 2.avi.ff.avi";
f6= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /2. Films/nuvens 3.avi.ff.avi";
f7= "/Users/tiagocutileiro/Music/em trabalho/1 - esbocos/opera 2/tese/multimedia elements /2. Films/timeflies.mov.ff.avi";

film= f1;

//controlos
controls = SCWindow("films", Rect(640, 0, 500, 270));
controls.view.background = Color.grey(0.1);

//butões
// 1-escolhe film
button1 = Button(controls, Rect(50, 50, 100, 100))
    .canFocus_(false)
    .states_([

	["I"],
	["II"],
	["III"],
	["IV"],
	["V"],
	["VI"],
	["VII"]
    ])
    .action_({ arg it;
    var num = it.value;

    if(num == 0) 
	{
film = f1;
	};
	
if(num == 1) 
	{
film = f2;
	};
	
if(num == 2) 
	{
film = f3;
	};

if(num == 3) 
	{
film = f4;
	};
	
if(num == 4) 
	{
film = f5;
	};
	
if(num == 5) 
	{
film = f6;
	};
	
if(num == 6) 
	{
film = f7;
	};

    });

button1.font_(Font("Times", 50));

//butões
// 2-toca faixa
button2 = Button(controls, Rect(200, 50, 100, 100))
    .canFocus_(false)
    .states_([
	["play"],
	["stop"]
    ])
    .action_({ arg it;
    var num = it.value;

if(num == 1) 
	{

filmplay= Task({
	
	window = Window.new(bounds: Rect(width/20, 800, width-(width/20*2), width-(width/20*2)*0.425-16), border: false);
	window.view.background_(Color.black);
	window.front;

	0.5.wait;
	
	movie = MovieView(window, Rect(0, -16, width-(width/20*2), width-(width/20*2)*0.425));
	movie.showControllerAndAdjustSize(false, true);
	
	movie.path_(film);

	0.5.wait;
	movie.start;	
	
	600.wait;
	movie.stop;
	
	2.wait;

	window.close;
	
}).play(AppClock, true); // vídeo necessita AppClock

	};
if(num == 0) 
	{
		
movie.stop;
filmplay.stop;
window.close;
//controls.close;
filmplay.free;

	}
    });
button2.font_(Font("Lucida Grande", 12));

//butões
// 3-stop
button3 = Button(controls, Rect(350, 50, 100, 100))
    .canFocus_(false)
    .states_([
	["pause"],
	["resume"]
    ])
    .action_({ arg it;
    var num = it.value;

if(num == 0) 
	{
		
movie.start;

	};
	
if(num == 1) 
	{
		
movie.stop;

	};
    });
button3.font_(Font("Lucida Grande", 12));

controls.front;

CmdPeriod.doOnce{if(window.isClosed.not, {window.close})};
CmdPeriod.doOnce{if(controls.isClosed.not, {controls.close})};
)