this code is from media player, that works very well for a long time, so there should be no problem,
(except of some small mistakes of mine )