I could even hear the sound from the speaker when I use this command.
speaker-test -c2 -t wav
Currently I want to play a MP3 file. I checked online and for command line playback I can people suggested using omxplayer. I tried using that I canno’t hear anything out of the speaker. May I know what is the mistake I am making?
until recently omxplayer had no support for ALSA, so it couldn’t be used with devices communicating over I2S.
I have read very recently, here, that it does at this stage. You would almost certainly have to compile it from source however, as the version available in Raspbian is no doubt much older than required.
My recommendation, if all you want to do is playback mp3s, would be to use something like mpg321, which probably satisfy your needs and won’t require the complexity of getting omxplayer compiled with ALSA support.