[R] Playing a music file in R

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Thu Jul 23 09:57:34 CEST 2020


Thie "system" command in R takes the first argument and passes that to
the shell in which R is running.
1) I run R in the bash shell under Fedora Linux version 30
2) I have installed "mplayer" as an audio/visual player that can be
called from the bash shell
3) The command I pass says "Start the mplayer program using the first
argument as the file to process.

One method is to find the easiest way to play an audio/visual file on
your system and then call it from R using "system".
Other ways using R packages have been suggested by other respondents.

Jim

On Thu, Jul 23, 2020 at 5:26 PM Vahid Borji <vahid.borji65 using gmail.com> wrote:
>
> Dear Jim,
>
> Thank you for your answer.
>
> I have a question for you.
>
> This is your code: system("mplayer /home/jim/songs/bimbo_soul.mp3",
>  wait=FALSE,ignore.stdout=TRUE)
>
> 1. Which part of your code is related to call a music player?
>
> 2. Which part is related to call a music file?
>
> I want to do this on my laptop, so I need to understand your code (the answer to the above questions).
>
> Regards,
> Vahid
>
>
> On Wed, Jul 22, 2020 at 1:45 AM Jim Lemon <drjimlemon using gmail.com> wrote:
>>
>> Hi Vahid,
>> The following command:
>>
>> system("mplayer /home/jim/songs/bimbo_soul.mp3",
>>  wait=FALSE,ignore.stdout=TRUE)
>>
>> works fine for me. Of course you'll have to specify a music player and
>> music file that you have...
>>
>> Jim
>>
>> On Wed, Jul 22, 2020 at 4:02 AM Vahid Borji <vahid.borji65 using gmail.com> wrote:
>> >
>> > Hello my R friends,
>> >
>> > How can we call a music file from our laptop (for example from desktop) and
>> > play it in R? Could you please give me an explicit example by writing
>> > commands in R. Is it necessary for our music file to be in a specific
>> > format? If yes, which format it has to be?
>> >
>> > Thank you in advance
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list