forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Playing MP3's in VDS?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Tue Sep 28, 2010 10:56 am    Post subject: Playing MP3's in VDS? Reply with quote

Hi All,

What is the best way to play an .mp3 file via VDS? I know there were (are?) some .dlls out there to do the trick, but what about using MCI? Would anyone happen to have any examples?

Thanks,

- Boo
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Tue Sep 28, 2010 10:43 pm    Post subject: Reply with quote

Man, is this forum dead or what? 8-(
Back to top
View user's profile Send private message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Wed Sep 29, 2010 2:49 am    Post subject: Reply with quote

Hi

there are still some zombies around Wink

Did you already try "shell play,yoursong.mp3" ?
.
Back to top
View user's profile Send private message Visit poster's website
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Sep 29, 2010 3:39 am    Post subject: Reply with quote

A fellow zombie! Cool

Yep, tried that. I need a solution that will play the .mp3 in the background, without launching an external program. Also, it needs to be fast.

Like:

PLAY myfile.wav, WAIT

But an .mp3 file...

Oh well; suppose I'll just stick with .wav files...

Greetings from Florida!

- Boo
Back to top
View user's profile Send private message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Wed Sep 29, 2010 4:19 am    Post subject: Reply with quote

This works fine on my Xp-machine.

Code:

  runh "C:\Programme\Windows Media Player\wmplayer.exe" "c:\temp\test.mp3"



The quotings and the full path seem to be necessary. With a "wait" at the end, my IDE hangs/crashes.

Greetings from Berlin/Germany.
.
Back to top
View user's profile Send private message Visit poster's website
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Sep 29, 2010 4:38 am    Post subject: Reply with quote

Yep, that works, albeit I have to enter it as follows on my machine:

Code:

runh "C:\Program Files\Windows Media Player\wmplayer.exe" "c:\temp\test.mp3"


Problem is, if the user has her/his Windows Media Player set to loop, then the damn thing keeps playing. Also, a bit of a delay there (unlike when using the Play command with a .wav. file)...

But thanks (and it is nice to get a response on this forum these days),

- Boo
Back to top
View user's profile Send private message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Wed Sep 29, 2010 12:44 pm    Post subject: Reply with quote

If you know the length of the title to play, you can loop after the command and compute the time, then close the hidden player window.

The delay is the time that wmplayer needs to start. You could use mplayer2.exe from WinXP (only 5kB in size) as an included resource, which should load faster. there also is a commandline for it:

Code:

  runh "C:\temp\mplayer2.exe" /play /close "c:\temp\test.mp3"


The looping-modus is found in registry under

HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Player\Settings\PlayCount

If the value is set to "0" then looping is enabled. You can set it temporarly to "1", play your file and set it back afterwards.
This should work without admin-privileges too, cause it's a user-specific setting.


Edit: Found out how to do it with MCI

Here we go:
Code:

  %R = @MCI(close "c:\temp\test.mp3")
  %R = @MCI(open "c:\temp\test.mp3")
  if @ok()
      %R = @MCI(play "c:\temp\test.mp3" wait)
      %R = @MCI(close "c:\temp\test.mp3")
    else
      warn Error in MCI-Command: %R
  end


The first "close" is to ensure that the device name is not in use.
This happens, if an error occurs or if you stop the script while the title is playing.

Greetings. bornSoft
.
Back to top
View user's profile Send private message Visit poster's website
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Sep 29, 2010 8:28 pm    Post subject: Reply with quote

Thanks bornsoft. This works, although there is still a discernible delay in there. Will keep playing with it... Cool
Back to top
View user's profile Send private message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Wed Sep 29, 2010 9:15 pm    Post subject: Reply with quote

I think this delay is the time that is needed to decode mp3-codec and depends from the system speed and cpu-load. I guess it's unavoidable.

You could try to @mci(open ...) at the beginning of your program and later play it, eventually it starts faster then.


Last edited by bornsoft on Wed Sep 29, 2010 9:24 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Sep 29, 2010 9:17 pm    Post subject: Reply with quote

Yep; I agree. I might just stick with using .wav files (although I hate the larger file sizes). FYI: I am adding audio pronunciations to a dictionary application that I'm working on...
Back to top
View user's profile Send private message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Wed Sep 29, 2010 9:23 pm    Post subject: Reply with quote

How about doing it in html with a browser element?

Have a look at the sourcecode of this dictionary-website:

http://dict.tu-chemnitz.de/dings.cgi?lang=en

Edit: Just found this intresting thing:

http://emff.sourceforge.net/
Back to top
View user's profile Send private message Visit poster's website
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Sep 29, 2010 11:19 pm    Post subject: Reply with quote

Hi Again,

That will not work for my needs, but thanks for the links. Very interesting!

Cheers,

- Boo
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Fri Oct 01, 2010 8:14 am    Post subject: Reply with quote

FYI: This code works great...

Code:
%M = C:\Files\myfile.mp3
%A = @MCI(Close mp3)
%A = @MCI(open %M alias mp3)
%A = @mci(cue mp3 output wait)
%A = @MCI(Play mp3)
Back to top
View user's profile Send private message
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Fri Oct 01, 2010 8:40 pm    Post subject: Reply with quote

Hi,
some years ago I writed this script to play mp3 files.
It's very simple but maybe canbe usefull to you (I hope)

Code:
  %P = 0
  %%Pausa =
  OPTION DECIMALSEP,"."
  TITLE EaPlayer 1.1   
  DIALOG CREATE,Player,-1,0,340,491,SAVEPOS,DRAGDROP
  DIALOG ADD,STYLE,STYLE3,Times New Roman,8,,,
  DIALOG ADD,STYLE,STYLE1,Verdana,10,,,
  DIALOG ADD,STYLE,STYLE2,Webdings,12,,BLACK,12,,BLACK,
  DIALOG ADD,BUTTON,Play,117,113,28,32,4,,STYLE2
  DIALOG ADD,BUTTON,Pause,117,144,39,32,;,,STYLE2
  DIALOG ADD,BUTTON,Resume,117,189,38,32,4,,STYLE2
  DIALOG ADD,BUTTON,Stop,118,74,35,32,g,,STYLE2
  DIALOG ADD,BUTTON,BROWSE,34,313,22,22,..
  DIALOG ADD,EDIT,File,34,11,300,22,,,READONLY
  DIALOG DISABLE,Pause
  DIALOG Disable,Resume
  DIALOG Disable,Stop
  DIALOG ADD,TEXT,TEXT1,126,266
  DIALOG ADD,TEXT,TEXT2,124,290
  DIALOG ADD,TEXT,TEXT3,126,316
  DIALOG ADD,TRACKBAR,TRACKBAR1,66,114,222,42,0,,,BOTH,CLICK
  DIALOG ADD,TEXT,TEXT4,16,13,,,File Audio da eseguire:,,STYLE1
  DIALOG ADD,TEXT,TEXT5,81,11,,,Posizione Brano,,STYLE1
  DIALOG ADD,TEXT,pos,118,244,,,pos,,STYLE1
  DIALOG ADD,LIST,LIST1,157,13,313,319,,STYLE3
  DIALOG SHOW
  HotKey Add,Play,F2
  HotKey Add,Pausa,F3
  HotKey Add,Fw,F7
  HotKey Add,FF,F8
:EvLoop
Wait Event,0.1
Goto @Event()



:HotKey
%h = @HotKey()

If @Equal(%h,PLAY)
  If %P
    Goto ResumeButton
  Else
    Goto PauseButton
  End 
ElsIf @Equal(%h,Pausa)
  Goto PauseButton
ElsIf @Equal(%h,FF)
  Goto FfButton
ElsIf @Equal(%h,Fw)
  Goto FwButton
End
Goto Loop

:Timer
%%Pos = @Mci(status media position)
Dialog Set,Pos,%%Pos
If @Numeric(%I)
 If @Zero(%P)
   If @Equal(%L,%I)
    Goto StopBUTTON
    End
   End
End
IF @NOT(@MOUSEDOWN(L))
  %L = @MCI(status media length)
  %I = @MCI(status media position)
  IF @NUMERIC(%L)
    IF @GREATER(%L,%I)
      %Q = @FDIV(%I,%L)
      DIALOG SET,TRACKBAR1,@FORMAT(@FMUL(@FDIV(%I,%L),100),4.0)
    END
  END
END
GOTO EVLOOP

:DragDrop
  List Create,1
  List DropFiles,1
  %F = @Next(1)
  List Close,1
  %F = @ShortName(%F)
  Dialog Set,File,%f
  List Add,List1,%f
  Goto EvLoop

:BROWSEBUTTON
%A = @FileDlg("Mp3 Files (*.mp3)|*.mp3",Apri File Audio,,Open)
If @Not(@Null(%A))
%A = @ShortName(%A)
Dialog Sset,File,%A
End
Goto EvLoop

:PlayBUTTON
DIALOG Enable,Pause
DIALOG Enable,Stop
DIALOG Disable,Play
%M = @DLGTEXT(File)
%A = @MCI(open %M alias media wait)
%A = @mci(cue media output wait)
%A = @MCI(Play media)
GOTO EVLOOP

:PauseBUTTON
%P = 1
DIALOG Enable,Resume
DIALOG Disable,Pause
%A = @MCI(pause media)
GOTO EVLOOP

:ResumeBUTTON
%P = 0
DIALOG Enable,Pause
DIALOG Disable,Resume
%A = @MCI(play media)
GOTO EVLOOP
%A = @MCI(seek media)


:FfButton
%%POS1 = @Fadd(%%Pos,1000)
#%A = @MCI(Seek media to @FORMAT(@fmul(@fdiv(%L,100),%%Pos1),4.0))
%A = @MCI(Seek media to %%Pos1)
WAIT 0.3
%A = @MCI(play media)
Goto EvLoop

:FwButton
%%pos1 = @Fsub(%%Pos,1000)
%A = @MCI(Seek media to %%Pos1)
WAIT 0.3
%A = @MCI(play media)
Goto EvLoop

:TRACKBAR1CLICK
IF @NUMERIC(%L)
%A = @MCI(Seek media to @FORMAT(@fmul(@fdiv(%L,100),@dlgtext(TRACKBAR1)),4.0))
WAIT 0.3
%A = @MCI(play media)
ELSE
 DIALOG SET,TRACKBAR1,0
END
GOTO EVLOOP

:StopBUTTON
%P = 0
%I = 0
DIALOG SET,TRACKBAR1,0
DIALOG DISABLE,Pause
DIALOG Enable,Play
DIALOG Disable,Pause
DIALOG Disable,Resume
DIALOG Disable,Stop
%A = @MCI(stop media)
%A = @MCI(close media)
GOTO EVLOOP

:CLOSE
%A = @MCI(stop media)
%A = @MCI(close media)
EXIT


Good luck Smile
Back to top
View user's profile Send private message Send e-mail
marcelo
Contributor
Contributor


Joined: 10 May 2008
Posts: 155

PostPosted: Fri Oct 08, 2010 10:18 pm    Post subject: Reply with quote

You can try VDSMPEG.DLL too. It's a good idea if you need to read MP3 Tags, runing time, actual position, etc
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group