Is there something wrong with this algorithm? --- Media Player