 //
 
 import Foundation
+import AVFoundation
 
 class PlayItem : NSObject {
 	var name : String = "item"

					newIndexOffset += 1
				}
			}

			//	For playlist items renumber the rank
			if tableView == playitemTableView {
				var rank = 1

				for item in playitemArrayController.arrangedObjects as! [AnyObject] {
					print("item.rank \(item.rank) -> \(rank)")
					item.setValue(rank, forKey: "rank")
					rank += 1;
				}
			}
			tableView.endUpdates()
		}
		
		return true
	}
	

	func tableView(tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableViewDropOperation) -> NSDragOperation {

		if dropOperation == .Above {
			let pboard = info.draggingPasteboard();
			let options = [NSPasteboardURLReadingFileURLsOnlyKey : true,
			               NSPasteboardURLReadingContentsConformToTypesKey : [kUTTypeMovie as String]]
			let items = pboard.readObjectsForClasses([NSURL.classForCoder()], options: options)
			if items!.count > 0 {
				for item in items! {
					if item.isFileReferenceURL() {
						let fileURL : NSURL? = item.filePathURL
						
						//	if it's a video file, get and set window content size to its dimentions
						let track0 = AVURLAsset(URL:fileURL!, options:nil).tracks[0]
						if track0.mediaType != AVMediaTypeVideo
						{
							print("validate nonAV -> .None")
							return .None
						}
						
						let path = fileURL!.absoluteString.stringByRemovingPercentEncoding
						print("validate file \(path)")
					} else {
						print("validate item -> \(item)")
					}
				}
			}
			print("validate Above -> .Move")
			return .Move
		}
		print("validate other -> .None")
		return .None
	}
	
	func tableView(tableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableViewDropOperation) -> Bool {
		let pasteboard = info.draggingPasteboard()
		let options = [NSPasteboardURLReadingFileURLsOnlyKey : true,
		               NSPasteboardURLReadingContentsConformToTypesKey : [kUTTypeMovie as String]]
		var oldIndexes = [Int]()
		var items : [AnyObject]
print("acceptDrop")

		tableView.beginUpdates()

		//	we have intra tableView drag-n-drop ?
		info.enumerateDraggingItemsWithOptions([], forView: tableView, classes: [NSPasteboardItem.self], searchOptions: [:]) {
			if let str = ($0.0.item as! NSPasteboardItem).stringForType("public.data"), index = Int(str) {
				oldIndexes.append(index)
			}
			// For simplicity, the code below uses `tableView.moveRowAtIndex` to move rows around directly.
			// You may want to move rows in your content array and then call `tableView.reloadData()` instead.
			var oldIndexOffset = 0
			var newIndexOffset = 0
			
			for oldIndex in oldIndexes {
				if oldIndex < row {
