play audio through bluetooth speakers in 12.04 using CLI












5














I have gone through the whole gamut of trials with setting up playing audio through bluetooth and have not been able to make it work reliably (i.e., got it to work one time, and has not worked after rebooting).



I can see the bluetooth interface (hciconfig) and can see the speaker (D100 creative) in a hcinconfig scan, but run into problems with bluez. The documentation is terrible and has not changed much since this guy wrote about it. I really do not want to talk about or debug this issue further. I am beaten and worn out on this issue.



However, I seem to have better luck connecting to the D100 using the default ubuntu gui. I can get the sound to work through the bluetooth speakers and I get sound when I click on the "test sound" button. How can I do this same thing using command line? Where can I find out what the bluetooth/sound app uses in the backend to make this work and play an mp3/wav file?










share|improve this question
























  • See if my answer to the following questions meets your needs: askubuntu.com/questions/48001/…
    – Takkat
    May 15 '13 at 19:08












  • @Takkat Thanks for that link and will try it out today. Once I succeed in connecting, how can you play an mp3/wav file (updated the question). I have tried aplay, mplayer unsuccessfully - what do you do?
    – Trewq
    May 15 '13 at 19:51










  • aplay can only play raw file, no mp3. For mp3 playback with mplayer you need to have the mp3 codes installed. See askubuntu.com/questions/44443/command-line-audio-players for a list of CLI players.
    – Takkat
    May 15 '13 at 20:19
















5














I have gone through the whole gamut of trials with setting up playing audio through bluetooth and have not been able to make it work reliably (i.e., got it to work one time, and has not worked after rebooting).



I can see the bluetooth interface (hciconfig) and can see the speaker (D100 creative) in a hcinconfig scan, but run into problems with bluez. The documentation is terrible and has not changed much since this guy wrote about it. I really do not want to talk about or debug this issue further. I am beaten and worn out on this issue.



However, I seem to have better luck connecting to the D100 using the default ubuntu gui. I can get the sound to work through the bluetooth speakers and I get sound when I click on the "test sound" button. How can I do this same thing using command line? Where can I find out what the bluetooth/sound app uses in the backend to make this work and play an mp3/wav file?










share|improve this question
























  • See if my answer to the following questions meets your needs: askubuntu.com/questions/48001/…
    – Takkat
    May 15 '13 at 19:08












  • @Takkat Thanks for that link and will try it out today. Once I succeed in connecting, how can you play an mp3/wav file (updated the question). I have tried aplay, mplayer unsuccessfully - what do you do?
    – Trewq
    May 15 '13 at 19:51










  • aplay can only play raw file, no mp3. For mp3 playback with mplayer you need to have the mp3 codes installed. See askubuntu.com/questions/44443/command-line-audio-players for a list of CLI players.
    – Takkat
    May 15 '13 at 20:19














5












5








5


1





I have gone through the whole gamut of trials with setting up playing audio through bluetooth and have not been able to make it work reliably (i.e., got it to work one time, and has not worked after rebooting).



I can see the bluetooth interface (hciconfig) and can see the speaker (D100 creative) in a hcinconfig scan, but run into problems with bluez. The documentation is terrible and has not changed much since this guy wrote about it. I really do not want to talk about or debug this issue further. I am beaten and worn out on this issue.



However, I seem to have better luck connecting to the D100 using the default ubuntu gui. I can get the sound to work through the bluetooth speakers and I get sound when I click on the "test sound" button. How can I do this same thing using command line? Where can I find out what the bluetooth/sound app uses in the backend to make this work and play an mp3/wav file?










share|improve this question















I have gone through the whole gamut of trials with setting up playing audio through bluetooth and have not been able to make it work reliably (i.e., got it to work one time, and has not worked after rebooting).



I can see the bluetooth interface (hciconfig) and can see the speaker (D100 creative) in a hcinconfig scan, but run into problems with bluez. The documentation is terrible and has not changed much since this guy wrote about it. I really do not want to talk about or debug this issue further. I am beaten and worn out on this issue.



However, I seem to have better luck connecting to the D100 using the default ubuntu gui. I can get the sound to work through the bluetooth speakers and I get sound when I click on the "test sound" button. How can I do this same thing using command line? Where can I find out what the bluetooth/sound app uses in the backend to make this work and play an mp3/wav file?







12.04 sound bluetooth pulseaudio alsa






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 27 '16 at 15:15









Benny Bottema

1013




1013










asked May 15 '13 at 15:51









Trewq

12613




12613












  • See if my answer to the following questions meets your needs: askubuntu.com/questions/48001/…
    – Takkat
    May 15 '13 at 19:08












  • @Takkat Thanks for that link and will try it out today. Once I succeed in connecting, how can you play an mp3/wav file (updated the question). I have tried aplay, mplayer unsuccessfully - what do you do?
    – Trewq
    May 15 '13 at 19:51










  • aplay can only play raw file, no mp3. For mp3 playback with mplayer you need to have the mp3 codes installed. See askubuntu.com/questions/44443/command-line-audio-players for a list of CLI players.
    – Takkat
    May 15 '13 at 20:19


















  • See if my answer to the following questions meets your needs: askubuntu.com/questions/48001/…
    – Takkat
    May 15 '13 at 19:08












  • @Takkat Thanks for that link and will try it out today. Once I succeed in connecting, how can you play an mp3/wav file (updated the question). I have tried aplay, mplayer unsuccessfully - what do you do?
    – Trewq
    May 15 '13 at 19:51










  • aplay can only play raw file, no mp3. For mp3 playback with mplayer you need to have the mp3 codes installed. See askubuntu.com/questions/44443/command-line-audio-players for a list of CLI players.
    – Takkat
    May 15 '13 at 20:19
















See if my answer to the following questions meets your needs: askubuntu.com/questions/48001/…
– Takkat
May 15 '13 at 19:08






See if my answer to the following questions meets your needs: askubuntu.com/questions/48001/…
– Takkat
May 15 '13 at 19:08














@Takkat Thanks for that link and will try it out today. Once I succeed in connecting, how can you play an mp3/wav file (updated the question). I have tried aplay, mplayer unsuccessfully - what do you do?
– Trewq
May 15 '13 at 19:51




@Takkat Thanks for that link and will try it out today. Once I succeed in connecting, how can you play an mp3/wav file (updated the question). I have tried aplay, mplayer unsuccessfully - what do you do?
– Trewq
May 15 '13 at 19:51












aplay can only play raw file, no mp3. For mp3 playback with mplayer you need to have the mp3 codes installed. See askubuntu.com/questions/44443/command-line-audio-players for a list of CLI players.
– Takkat
May 15 '13 at 20:19




aplay can only play raw file, no mp3. For mp3 playback with mplayer you need to have the mp3 codes installed. See askubuntu.com/questions/44443/command-line-audio-players for a list of CLI players.
– Takkat
May 15 '13 at 20:19










1 Answer
1






active

oldest

votes


















0














I use this to connect (or disconnect) to my bluetooth radio.



To find the MAC address of your bluetooth device, you could do this, which should show MAC addresses and names of devices you have paired with your system:



find /var/lib/bluetooth -name names | xargs cat


Then edit the mac=... line in this script and try it.



#!/bin/bash

mac="90:03:B7:17:00:08" # replace with correct MAC address of your bluetooth speaker

if [ "$1" = "off" ]; then
bt-audio -d "$mac"
exit $?
fi

bt-audio -c "$mac"

sink=$(pactl list short sinks | grep bluez | awk '{print $2}')

if [ -n "$sink" ]; then
pacmd set-default-sink "$sink" && echo OK
else
echo could not find sink
fi


Depending on your music player, you may need to stop and restart it's playback to make it pick up the new output.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f295820%2fplay-audio-through-bluetooth-speakers-in-12-04-using-cli%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I use this to connect (or disconnect) to my bluetooth radio.



    To find the MAC address of your bluetooth device, you could do this, which should show MAC addresses and names of devices you have paired with your system:



    find /var/lib/bluetooth -name names | xargs cat


    Then edit the mac=... line in this script and try it.



    #!/bin/bash

    mac="90:03:B7:17:00:08" # replace with correct MAC address of your bluetooth speaker

    if [ "$1" = "off" ]; then
    bt-audio -d "$mac"
    exit $?
    fi

    bt-audio -c "$mac"

    sink=$(pactl list short sinks | grep bluez | awk '{print $2}')

    if [ -n "$sink" ]; then
    pacmd set-default-sink "$sink" && echo OK
    else
    echo could not find sink
    fi


    Depending on your music player, you may need to stop and restart it's playback to make it pick up the new output.






    share|improve this answer


























      0














      I use this to connect (or disconnect) to my bluetooth radio.



      To find the MAC address of your bluetooth device, you could do this, which should show MAC addresses and names of devices you have paired with your system:



      find /var/lib/bluetooth -name names | xargs cat


      Then edit the mac=... line in this script and try it.



      #!/bin/bash

      mac="90:03:B7:17:00:08" # replace with correct MAC address of your bluetooth speaker

      if [ "$1" = "off" ]; then
      bt-audio -d "$mac"
      exit $?
      fi

      bt-audio -c "$mac"

      sink=$(pactl list short sinks | grep bluez | awk '{print $2}')

      if [ -n "$sink" ]; then
      pacmd set-default-sink "$sink" && echo OK
      else
      echo could not find sink
      fi


      Depending on your music player, you may need to stop and restart it's playback to make it pick up the new output.






      share|improve this answer
























        0












        0








        0






        I use this to connect (or disconnect) to my bluetooth radio.



        To find the MAC address of your bluetooth device, you could do this, which should show MAC addresses and names of devices you have paired with your system:



        find /var/lib/bluetooth -name names | xargs cat


        Then edit the mac=... line in this script and try it.



        #!/bin/bash

        mac="90:03:B7:17:00:08" # replace with correct MAC address of your bluetooth speaker

        if [ "$1" = "off" ]; then
        bt-audio -d "$mac"
        exit $?
        fi

        bt-audio -c "$mac"

        sink=$(pactl list short sinks | grep bluez | awk '{print $2}')

        if [ -n "$sink" ]; then
        pacmd set-default-sink "$sink" && echo OK
        else
        echo could not find sink
        fi


        Depending on your music player, you may need to stop and restart it's playback to make it pick up the new output.






        share|improve this answer












        I use this to connect (or disconnect) to my bluetooth radio.



        To find the MAC address of your bluetooth device, you could do this, which should show MAC addresses and names of devices you have paired with your system:



        find /var/lib/bluetooth -name names | xargs cat


        Then edit the mac=... line in this script and try it.



        #!/bin/bash

        mac="90:03:B7:17:00:08" # replace with correct MAC address of your bluetooth speaker

        if [ "$1" = "off" ]; then
        bt-audio -d "$mac"
        exit $?
        fi

        bt-audio -c "$mac"

        sink=$(pactl list short sinks | grep bluez | awk '{print $2}')

        if [ -n "$sink" ]; then
        pacmd set-default-sink "$sink" && echo OK
        else
        echo could not find sink
        fi


        Depending on your music player, you may need to stop and restart it's playback to make it pick up the new output.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 17 '15 at 13:36









        mivk

        2,3132334




        2,3132334






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f295820%2fplay-audio-through-bluetooth-speakers-in-12-04-using-cli%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?