When a DVD is inserted into the drive, it will play and work as normal, however it refuses to eject. I've tried via the command line as well as the eject button. I remember a while back finding some code to add to a file (not helpful, I know!) which basically prevented the drive from locking. Can anyone point me in the right direction?
It is not a good idea to eject a disc while it is mounted into the file system. Many application don't expect that and might not work properly anymore. Also in some rare cases a forced eject can to physical damage to the drive or media. To prevent ejecting a mounted media Linux usually prevents to eject via the the button on the drive. If the disk in unmounted, you eject normally.
The most easy way to do that is to use Nautilus (the file manager) and click the eject button next to the drive. This will unmount and eject the disc. In XBMC there is usually an option to do that as well, where depends on the used skin.
You can control the locking behavior with the eject command:
eject -i on /dev/cdrom eject -i off /dev/cdrom
man eject will give you a list of arguments you can supply to
eject some might also be helpful in getting more control over the drive's ejection behavior.