If you truly want help, you need to also provide all makes/model numbers. Hopefully you are aware by now that these components often differ in their functionality/options/ports/etc.
Before we know that though, this is why I often avoid soundbars and stick with a traditional AV receiver. Even a lower end receiver has what we usually need to avoid the nonsense you are experiencing. E.g. ample inputs & audio delay adjustment settings
My 'recipe'. FWIW, Some sort of audio switcher might help/may be required if the soundbar lacks inputs- which they often do.
Skybox (HDMI out) --> (HDMI in HDTV)
HDTV (digital optical out) --> (digital optical in) 3x1 or 2x1 digital optical switcher (can be manual or remote controlled switch)
Xbox (Analog out) --> (analog in) HDTV
Blu Ray player (HDMI out) --> (HDMI in) HDTV
"" "" (digital optical out) --> (digital optical in) digital optical switcher
Digital optical switcher (digital optical out) --> (digital optical in) Sony soundbar
Example of manual & remote controlled switchers. $15 would get your foot in the door
manual switch- http://www.amazon.com/Nyrius-SW100-Digital-Selector-Compatible/dp/B000812QC6/ref=cm_cr_pr_sims_t
remote version- http://www.amazon.com/ViewHD-TOSLINK-Digital-Optical-Switcher/product-reviews/B00G188Z7A/ref=cm_cr_dp_synop?ie=UTF8&showViewpoints=0&sortBy=bySubmissionDateDescending#R2N6388MSYW5D
*also, you could skip audio to the HDTV altogether, and simply run all three digital optical cables through a switcher, then onward to the soundbar. Ideally the TV is used as a monitor only. No digital outputs on that Xbox?
So i have a Sony TV, Sony Blu ray an X box and just bought a Sony sound bar. I also have a Sky box
The Sky box is HDMI'd into the TV port 1
The Blu ray id HDMI'd into the TV port 2
The X box is connected via the audio/vid in analogue
The TV is connected to the sound bar via optical in - out cable.
It all works brilliantly except for the Blu ray which has a time lag on the sound. The Sound bar has an advanced settings menu item for switching 'on' when this happens but I've tried doing that and it seems to have no effect. I notice there are other audio outs on the tv (for eg a USB audio out). Would using this instead of the optical to connect the sound bar make any difference???