Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Question

Posted

How to play a mp3 file in my sonos using LUA?

I'm using krikroffs vd for basic sonos and tts but miss this feature.

17 answers to this question

Recommended Posts

  • 0
Posted

Hi KristioanO try with

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

    Thanks! I added the IP/port and changed the library. Added the complete code to a button. Still got this.

    [DEBUG] 07:15:13: socket status: 


    [DEBUG] 07:15:13: socket err: Wrong arguments for overloaded function 'new_FTcpSocket' Possible C/C++ prototypes are: FTcpSocket::FTcpSocket() FTcpSocket::FTcpSocket(string const &,int)

    • 0
    Posted

    That's strange. See this yesterday

    Please login or register to see this link.

     

     

    Brian

    • 0
  • Inquirer
  • Posted

    Yes, it's working! Just a stupid copy/paste error.

    Thanks a lot!

    • 0
    Posted

    Nice to have it confurmed. I spent a long time on the other copy tring to get it to work.

     

    Brian

    • 0
  • Inquirer
  • Posted

    No, sorry i was jumping to quickly. Its not working... It was just running thru, but no sound at all.

     

    Debug:

    [DEBUG] 16:22:21: unMute sent

    [DEBUG] 16:22:21: Volume set: 20
    [DEBUG] 16:22:22: retry #0 action: Play
    [DEBUG] 16:22:22: play sent
    [DEBUG] 16:22:23: retry #0 action: GetTransportInfo
    [DEBUG] 16:22:23: 
    [DEBUG] 16:22:28: STOPPED
    [DEBUG] 16:22:31: stop sent
    [DEBUG] 16:22:31: Volume set: 25

    • 0
    Posted

    This is my debug screen if it is a help.

     

    [DEBUG] 18:48:20: unMute sent
    [DEBUG] 18:48:20: Volume set: 50
    [DEBUG] 18:48:20: play sent
    [DEBUG] 18:48:20: TRANSITIONING
    [DEBUG] 18:48:25: PLAYING
    [DEBUG] 18:48:30: STOPPED
    [DEBUG] 18:48:33: stop sent
    [DEBUG] 18:48:33: Volume set: 22

     

    and this is the playfile address on a RaspberryPi

     

    playFile ("//RASPBERRYPI/sounds/gong.mp3", 50 );

    • 0
    Posted

    Hi Krikroff, thanks for the code. It works OK in my setup.

    However, compared wtih your TTS VD I have noticed a couple of different behaviours:

     

    1.- Playing is limited to 20 secs (10 loops x 2 secs), and after that, stop is sent. That should be long enough for a TTS static message but I'm wondering why the TTS VD based on the toolkit seems to have the same code (limited to 120 secs) but never stops.

    2.- Function getCurrentTrack is not implemented and therefore the music beeing played when the TTS is activated never returns afterwards. Will you add this functionalty?

     

    Thanks.

    • 0
    Posted

    No, sorry i was jumping to quickly. Its not working... It was just running thru, but no sound at all.

     

    Debug:

    [DEBUG] 16:22:21: unMute sent

    [DEBUG] 16:22:21: Volume set: 20

    [DEBUG] 16:22:22: retry #0 action: Play

    [DEBUG] 16:22:22: play sent

    [DEBUG] 16:22:23: retry #0 action: GetTransportInfo

    [DEBUG] 16:22:23: 

    [DEBUG] 16:22:28: STOPPED

    [DEBUG] 16:22:31: stop sent

    [DEBUG] 16:22:31: Volume set: 25

    KristianO, it seems that the path or filename you are trying to play is wrong, because the HC2 is not reaching it according to your debug messages. Check it and include full path and file extension (.mp3 or whatever)

    • 0
  • Inquirer
  • Posted

    Thanks! Yes it seems like it. I have a OS X server running and think i have 2 options. The file sharing or to locate the file via the web server.

    I have tried both wo success. Any idea how to type the directory?

    eg. if the file is located at my server "IP_adress/Home/dogs_barking.mp3"

    • 0
    Posted

    Thanks! Yes it seems like it. I have a OS X server running and think i have 2 options. The file sharing or to locate the file via the web server.

    I have tried both wo success. Any idea how to type the directory?

    eg. if the file is located at my server "IP_adress/Home/dogs_barking.mp3"

    Try "//IP_adress/Home/dogs_barking.mp3"

    • 0
    Posted

    Thank you Krikroff for another fine piece of code. My favorite part is urlencode() 

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />

    • 0
  • Inquirer
  • Posted

    Brick: Tried that but not working... the log is different but still no sound.

    Please login or register to see this image.

    /emoticons/default_sad.png" alt=":(" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

     

    playFile("//10.0.1.10/Home/dogs_barking.mp3", 25);

     

    [DEBUG] 10:15:11: unMute sent


    [DEBUG] 10:15:11: play sent
    [DEBUG] 10:15:11: STOPPED
    [DEBUG] 10:15:16: STOPPED
    [DEBUG] 10:15:19: stop sent

     
     
    I can connect to the IP and locate the "Home" share wo usr/pwd. 
    • 0
    Posted

     

    Brick: Tried that but not working... the log is different but still no sound.

    Please login or register to see this image.

    /emoticons/default_sad.png" alt=":(" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

     

    playFile("//10.0.1.10/Home/dogs_barking.mp3", 25);

     

    [DEBUG] 10:15:11: unMute sent

    [DEBUG] 10:15:11: play sent

    [DEBUG] 10:15:11: STOPPED

    [DEBUG] 10:15:16: STOPPED

    [DEBUG] 10:15:19: stop sent

     
     
    I can connect to the IP and locate the "Home" share wo usr/pwd. 

     

    Can you find and play the file from Sonos app?

    • 0
  • Inquirer
  • Posted

    Problem solved:

    - Computer name = WINS name (Case sensitive)

    - Define Share with guest access

    • 0
    Posted

    Good to know.

    Now let's hope that Krikroff adds on the return-to-previous-track feature... 

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    • 0
    Posted

    I implemented this code with some tweaks. Love your work Krikroff!

     

    Works a charm other than every now and then the track being played is truncated and I am not talking about truncation after a long period of time. All my files are short ie less than 8 seconds. Sometimes the file gets a couple of seconds through and then stops playing. Has anyone else experienced this?

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...