Apache Cordova
  1. Apache Cordova
  2. CB-941

WP7 : Cannot play MP3/wav using MEDIA

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.8.0, 2.0.0
    • Fix Version/s: None
    • Component/s: WP7 (defunct)
    • Labels:
      None
    • Environment:

      Nokia Lumia 800 with WP 7.5 (7.10.8773.98). Cordova 2.0.0

      Description

      UPDATED with 2.0 and lastest WP7 OS version information (2012-08-09)

      2.0

      index.html

      [...]
              <title>Hello Cordova</title>
      <script>
        function MyInit()
        {
        document.getElementById("welcomeMsg").innerHTML += "Cordova is ready! version=" + window.device.cordova;
        console.log("onDeviceReady. You should see this message in Visual Studio's output window.");
        //  my_media = new Media("app/www/test.mp3");//ressource buildAction == content
        my_media = new Media("app/www/chord.wav");//ressource buildAction == content; copied from C:\Windows\Media
      
        my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
        }
      
        var playCounter = 0;
        var my_media = null;
        function playMP3(){
        console.log("playMP3() counter " + playCounter);
        my_media.play();
        playCounter++;
        }
      
        var my_media2 = null;
        function playMP32(){
        console.log("playMP32() counter " + playCounter);
        my_media2.play();
        playCounter++;
        }
      
      </script>
      
          </head>
          <body>
              <div id="welcomeMsg"></div>
              <div class="app">
                  <h1>Apache Cordova</h1>
                  <div id="deviceready">
                      <p class="status pending blink">Connecting to Device</p>
                      <p class="status complete blink hide">Device is Ready</p>
                  </div>
              </div>
              <script type="text/javascript" src="cordova-2.0.0.js"></script>
              <script type="text/javascript" src="js/index.js"></script>
              <script type="text/javascript">
                  app.initialize();
      			</script>
      
          <p onclick="playMP3();">Click to Play MP3</p>
          <p onclick="playMP32();">Click to Play MP3 2</p>
      
      
      			</body>
      </html>
      [EOF]
      

      index.js

      [...]
          deviceready: function() {
              // note that this is an event handler so the scope is that of the event
              // so we need to call app.report(), and not this.report()
              app.report('deviceready');
      		MyInit();
          },
      [...]
      

      output (debug config, terminal connected to Zune):

      'UI Task' (Managed): Loaded 'System.SR.dll'
      A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
      A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll
      Updating IsolatedStorage for APP:DeviceID :: [edited]
      INFO: Creating Directory :: /app/www
      INFO: Writing data for /app/www\chord.wav and length = 113964
      INFO: Creating Directory :: /app/www\js
      INFO: Writing data for /app/www\js\index.js and length = 792
      INFO: Writing data for /app/www\test.mp3 and length = 34396
      INFO: Writing data for /app/www\test2.mp3 and length = 34396
      INFO: Writing data for /app/www\cordova-2.0.0.js and length = 188657
      INFO: Creating Directory :: /app/www\css
      INFO: Writing data for /app/www\css\index.css and length = 2239
      INFO: Creating Directory :: /app/www\img
      INFO: Writing data for /app/www\img\cordova.png and length = 19932
      INFO: Writing data for /app/www\index.html and length = 1990
      GapBrowser_Navigated :: /app/www/index.html
      'UI Task' (Managed): Loaded 'System.ServiceModel.Web.dll'
      'UI Task' (Managed): Loaded 'System.ServiceModel.dll'
      The thread '<No Name>' (0x16490a2e) has exited with code 0 (0x0).
      The thread '<No Name>' (0x17630a6a) has exited with code 0 (0x0).
      Log:"report:deviceready"
      The thread '<No Name>' (0x16a507aa) has exited with code 0 (0x0).
      'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
      Log:"onDeviceReady. You should see this message in Visual Studio's output window."
      The thread '<No Name>' (0x173d0dbe) has exited with code 0 (0x0).
      The thread '<No Name>' (0x1731027e) has exited with code 0 (0x0).
      The thread '<No Name>' (0x162a0a4e) has exited with code 0 (0x0).
      Log:"playMP3() counter 0"
      A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
      The thread '<No Name>' (0x16cd082e) has exited with code 0 (0x0).
      The thread '<No Name>' (0x176d0d3a) has exited with code 0 (0x0).
      Log:"playMP32() counter 1"
      The thread '<No Name>' (0x16a808e6) has exited with code 0 (0x0).
      A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
      The thread '<No Name>' (0x179e0852) has exited with code 0 (0x0).
      

      My Config:

      • cordova : 2.0.0
      • Nokia Lumia 800
      • Version OS : 7.10.8773.98 (commercial : 7.5)
      • Microsoft Visual Studio 2010
        Version WPDTRTMRel - 40219.209
        Microsoft .NET Framework
        Version 4.0.30319 SP1Rel
        Installed Version: PD Express

      1.8 / (7.10.7740.16)

      The MP3 file is only played once (the first time).

      • If I create a new instance of MEDIA each time, the MP3 file is only played once (the first time).
      • If I keep alive the instance (create it in onDeviceReady), I can play multiple time the first mp3 I play. BUT, I cannot play the other mp3.

      note:

      • with version 1.6.1, turn OFF then ON the screen allow you to play one more time the mp3. Not with 1.8.0.
      • same issue with 1.6.1, but the error message are IOException & IsolatedStorageException with various "MEDIA on status" information.
            var playCounter = 0;
            var my_media = null;
            function playMP3(){
              console.log("playMP3()counter " + playCounter);
              if (!(my_media == null)){
                my_media.release(); //Cordova 1.8.0
              }
              my_media = new Media("app/www/test.mp3");//ressource buildAction == content
      
              my_media.play();
              playCounter++;
            }
      
            var my_media2 = null;
              function playMP32(){
              console.log("playMP32() counter " + playCounter);
              if (!(my_media2 == null)){
                my_media2.release(); //Cordova 1.8.0
              }
              my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
            my_media2.play();
            playCounter++;
            }
      
          [...]
          <p onclick="playMP3();">Click to Play MP3</p>
          <p onclick="playMP32();">Click to Play MP3 2</p>
      

      Log:

      Log:"onDeviceReady. You should see this message in Visual Studio's output window."
      'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
      Log:"playMP3() counter 0"
      'UI Task' (Managed): Loaded 'System.SR.dll'
      A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
      Log:"playMP3() counter 1"
      A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
      Dispose :: app/www/test.mp3
      A first chance exception of type 'System.NullReferenceException' occurred in WP7CordovaClassLib.dll
      A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
      Error: El parámetro es incorrecto. 
      Log:"playMP32() counter 2"
      INFO: startPlayingAudio could not find mediaPlayer for b5e8e480-de8b-ab2c-82a6-c60270f590f2
      A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
      Error: El parámetro es incorrecto. 
      
      1. test.mp3
        34 kB
        Christophe A. Guilmart
      2. chord.wav
        111 kB
        Christophe A. Guilmart
      3. index.js
        0.8 kB
        Christophe A. Guilmart
      4. index.html
        2 kB
        Christophe A. Guilmart

        Activity

        Christophe A. Guilmart created issue -
        Christophe A. Guilmart made changes -
        Field Original Value New Value
        Summary WP7 : Cannot play MP3 using MEDIA WP7 : Cannot play MP3/wav using MEDIA
        Affects Version/s 2.0.0 [ 12318875 ]
        Environment Nokia Lumia 800 with WP 7.5 (7.10.7740.16). 1.8.0rc1 Nokia Lumia 800 with WP 7.5 (7.10.8773.98). Cordova 2.0.0
        Description The MP3 file is only played once (the first time).

        * If I create a new instance of MEDIA each time, the MP3 file is only played once (the first time).

        * If I keep alive the instance (create it in onDeviceReady), I can play multiple time the first mp3 I play. BUT, I cannot play the other mp3.

        note:
        * with version 1.6.1, turn OFF then ON the screen allow you to play one more time the mp3. Not with 1.8.0.
        * same issue with 1.6.1, but the error message are IOException & IsolatedStorageException with various "MEDIA on status" information.


              var playCounter = 0;
              var my_media = null;
              function playMP3(){
                console.log("playMP3()counter " + playCounter);
                if (!(my_media == null)){
                  my_media.release(); //Cordova 1.8.0
                }
                my_media = new Media("app/www/test.mp3");//ressource buildAction == content

                my_media.play();
                playCounter++;
              }

              var my_media2 = null;
                function playMP32(){
                console.log("playMP32() counter " + playCounter);
                if (!(my_media2 == null)){
                  my_media2.release(); //Cordova 1.8.0
                }
                my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
              my_media2.play();
              playCounter++;
              }

            [...]
            <p onclick="playMP3();">Click to Play MP3</p>
            <p onclick="playMP32();">Click to Play MP3 2</p>


        Log:


        Log:"onDeviceReady. You should see this message in Visual Studio's output window."
        'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
        Log:"playMP3() counter 0"
        'UI Task' (Managed): Loaded 'System.SR.dll'
        A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
        Log:"playMP3() counter 1"
        A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
        Dispose :: app/www/test.mp3
        A first chance exception of type 'System.NullReferenceException' occurred in WP7CordovaClassLib.dll
        A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
        Error: El parámetro es incorrecto.
        Log:"playMP32() counter 2"
        INFO: startPlayingAudio could not find mediaPlayer for b5e8e480-de8b-ab2c-82a6-c60270f590f2
        A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
        Error: El parámetro es incorrecto.
        UPDATED with 2.0 and lastest WP7 OS version information (2012-08-09)

        == 2.0 ==
        * This is worst on Cordova 2.0.0 : the file is never played.
        * same result with VS configuration Debug and Release.
        * same result while the terminal is connected to Zune and while the terminal is not connected. (I tried this becasue of http://blogs.msdn.com/b/jaimer/archive/2010/11/03/tips-for-debugging-wp7-media-apps-with-wpconnect.aspx)
        * I also tried with a wav file. same result.

        index.html

        [...]
                <title>Hello Cordova</title>
        <script>
          function MyInit()
          {
          document.getElementById("welcomeMsg").innerHTML += "Cordova is ready! version=" + window.device.cordova;
          console.log("onDeviceReady. You should see this message in Visual Studio's output window.");
          // my_media = new Media("app/www/test.mp3");//ressource buildAction == content
          my_media = new Media("app/www/chord.wav");//ressource buildAction == content; copied from C:\Windows\Media

          my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
          }

          var playCounter = 0;
          var my_media = null;
          function playMP3(){
          console.log("playMP3() counter " + playCounter);
          my_media.play();
          playCounter++;
          }

          var my_media2 = null;
          function playMP32(){
          console.log("playMP32() counter " + playCounter);
          my_media2.play();
          playCounter++;
          }

        </script>

            </head>
            <body>
                <div id="welcomeMsg"></div>
                <div class="app">
                    <h1>Apache Cordova</h1>
                    <div id="deviceready">
                        <p class="status pending blink">Connecting to Device</p>
                        <p class="status complete blink hide">Device is Ready</p>
                    </div>
                </div>
                <script type="text/javascript" src="cordova-2.0.0.js"></script>
                <script type="text/javascript" src="js/index.js"></script>
                <script type="text/javascript">
                    app.initialize();
        </script>

            <p onclick="playMP3();">Click to Play MP3</p>
            <p onclick="playMP32();">Click to Play MP3 2</p>


        </body>
        </html>
        [EOF]


        index.js

        [...]
            deviceready: function() {
                // note that this is an event handler so the scope is that of the event
                // so we need to call app.report(), and not this.report()
                app.report('deviceready');
        MyInit();
            },
        [...]


        output debugconfig, terminal connected to Zune):

        'UI Task' (Managed): Loaded 'System.SR.dll'
        A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
        A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll
        Updating IsolatedStorage for APP:DeviceID :: [edited]
        INFO: Creating Directory :: /app/www
        INFO: Writing data for /app/www\chord.wav and length = 113964
        INFO: Creating Directory :: /app/www\js
        INFO: Writing data for /app/www\js\index.js and length = 792
        INFO: Writing data for /app/www\test.mp3 and length = 34396
        INFO: Writing data for /app/www\test2.mp3 and length = 34396
        INFO: Writing data for /app/www\cordova-2.0.0.js and length = 188657
        INFO: Creating Directory :: /app/www\css
        INFO: Writing data for /app/www\css\index.css and length = 2239
        INFO: Creating Directory :: /app/www\img
        INFO: Writing data for /app/www\img\cordova.png and length = 19932
        INFO: Writing data for /app/www\index.html and length = 1990
        GapBrowser_Navigated :: /app/www/index.html
        'UI Task' (Managed): Loaded 'System.ServiceModel.Web.dll'
        'UI Task' (Managed): Loaded 'System.ServiceModel.dll'
        The thread '<No Name>' (0x16490a2e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x17630a6a) has exited with code 0 (0x0).
        Log:"report:deviceready"
        The thread '<No Name>' (0x16a507aa) has exited with code 0 (0x0).
        'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
        Log:"onDeviceReady. You should see this message in Visual Studio's output window."
        The thread '<No Name>' (0x173d0dbe) has exited with code 0 (0x0).
        The thread '<No Name>' (0x1731027e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x162a0a4e) has exited with code 0 (0x0).
        Log:"playMP3() counter 0"
        A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
        The thread '<No Name>' (0x16cd082e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x176d0d3a) has exited with code 0 (0x0).
        Log:"playMP32() counter 1"
        The thread '<No Name>' (0x16a808e6) has exited with code 0 (0x0).
        A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
        The thread '<No Name>' (0x179e0852) has exited with code 0 (0x0).




        My Config:
        * cordova : 2.0.0
        * Nokia Lumia 800
        * Version OS : 7.10.8773.98 (commercial : 7.5)

        Microsoft Visual Studio 2010
        Version WPDTRTMRel - 40219.209
        Microsoft .NET Framework
        Version 4.0.30319 SP1Rel
        Installed Version: PD Express



        === 1.8 / (7.10.7740.16) ==
        The MP3 file is only played once (the first time).

        * If I create a new instance of MEDIA each time, the MP3 file is only played once (the first time).

        * If I keep alive the instance (create it in onDeviceReady), I can play multiple time the first mp3 I play. BUT, I cannot play the other mp3.

        note:
        * with version 1.6.1, turn OFF then ON the screen allow you to play one more time the mp3. Not with 1.8.0.
        * same issue with 1.6.1, but the error message are IOException & IsolatedStorageException with various "MEDIA on status" information.


              var playCounter = 0;
              var my_media = null;
              function playMP3(){
                console.log("playMP3()counter " + playCounter);
                if (!(my_media == null)){
                  my_media.release(); //Cordova 1.8.0
                }
                my_media = new Media("app/www/test.mp3");//ressource buildAction == content

                my_media.play();
                playCounter++;
              }

              var my_media2 = null;
                function playMP32(){
                console.log("playMP32() counter " + playCounter);
                if (!(my_media2 == null)){
                  my_media2.release(); //Cordova 1.8.0
                }
                my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
              my_media2.play();
              playCounter++;
              }

            [...]
            <p onclick="playMP3();">Click to Play MP3</p>
            <p onclick="playMP32();">Click to Play MP3 2</p>


        Log:


        Log:"onDeviceReady. You should see this message in Visual Studio's output window."
        'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
        Log:"playMP3() counter 0"
        'UI Task' (Managed): Loaded 'System.SR.dll'
        A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
        Log:"playMP3() counter 1"
        A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
        Dispose :: app/www/test.mp3
        A first chance exception of type 'System.NullReferenceException' occurred in WP7CordovaClassLib.dll
        A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
        Error: El parámetro es incorrecto.
        Log:"playMP32() counter 2"
        INFO: startPlayingAudio could not find mediaPlayer for b5e8e480-de8b-ab2c-82a6-c60270f590f2
        A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
        Error: El parámetro es incorrecto.
        Priority Major [ 3 ] Critical [ 2 ]
        Hide
        Christophe A. Guilmart added a comment -

        TEST CASE. start a new project with the template of 2.0.0 and replace the files by thoses. don't forget to set the build acction to content.

        Show
        Christophe A. Guilmart added a comment - TEST CASE. start a new project with the template of 2.0.0 and replace the files by thoses. don't forget to set the build acction to content.
        Christophe A. Guilmart made changes -
        Attachment index.html [ 12540019 ]
        Attachment index.js [ 12540020 ]
        Attachment chord.wav [ 12540021 ]
        Attachment test.mp3 [ 12540022 ]
        Christophe A. Guilmart made changes -
        Description UPDATED with 2.0 and lastest WP7 OS version information (2012-08-09)

        == 2.0 ==
        * This is worst on Cordova 2.0.0 : the file is never played.
        * same result with VS configuration Debug and Release.
        * same result while the terminal is connected to Zune and while the terminal is not connected. (I tried this becasue of http://blogs.msdn.com/b/jaimer/archive/2010/11/03/tips-for-debugging-wp7-media-apps-with-wpconnect.aspx)
        * I also tried with a wav file. same result.

        index.html

        [...]
                <title>Hello Cordova</title>
        <script>
          function MyInit()
          {
          document.getElementById("welcomeMsg").innerHTML += "Cordova is ready! version=" + window.device.cordova;
          console.log("onDeviceReady. You should see this message in Visual Studio's output window.");
          // my_media = new Media("app/www/test.mp3");//ressource buildAction == content
          my_media = new Media("app/www/chord.wav");//ressource buildAction == content; copied from C:\Windows\Media

          my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
          }

          var playCounter = 0;
          var my_media = null;
          function playMP3(){
          console.log("playMP3() counter " + playCounter);
          my_media.play();
          playCounter++;
          }

          var my_media2 = null;
          function playMP32(){
          console.log("playMP32() counter " + playCounter);
          my_media2.play();
          playCounter++;
          }

        </script>

            </head>
            <body>
                <div id="welcomeMsg"></div>
                <div class="app">
                    <h1>Apache Cordova</h1>
                    <div id="deviceready">
                        <p class="status pending blink">Connecting to Device</p>
                        <p class="status complete blink hide">Device is Ready</p>
                    </div>
                </div>
                <script type="text/javascript" src="cordova-2.0.0.js"></script>
                <script type="text/javascript" src="js/index.js"></script>
                <script type="text/javascript">
                    app.initialize();
        </script>

            <p onclick="playMP3();">Click to Play MP3</p>
            <p onclick="playMP32();">Click to Play MP3 2</p>


        </body>
        </html>
        [EOF]


        index.js

        [...]
            deviceready: function() {
                // note that this is an event handler so the scope is that of the event
                // so we need to call app.report(), and not this.report()
                app.report('deviceready');
        MyInit();
            },
        [...]


        output debugconfig, terminal connected to Zune):

        'UI Task' (Managed): Loaded 'System.SR.dll'
        A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
        A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll
        Updating IsolatedStorage for APP:DeviceID :: [edited]
        INFO: Creating Directory :: /app/www
        INFO: Writing data for /app/www\chord.wav and length = 113964
        INFO: Creating Directory :: /app/www\js
        INFO: Writing data for /app/www\js\index.js and length = 792
        INFO: Writing data for /app/www\test.mp3 and length = 34396
        INFO: Writing data for /app/www\test2.mp3 and length = 34396
        INFO: Writing data for /app/www\cordova-2.0.0.js and length = 188657
        INFO: Creating Directory :: /app/www\css
        INFO: Writing data for /app/www\css\index.css and length = 2239
        INFO: Creating Directory :: /app/www\img
        INFO: Writing data for /app/www\img\cordova.png and length = 19932
        INFO: Writing data for /app/www\index.html and length = 1990
        GapBrowser_Navigated :: /app/www/index.html
        'UI Task' (Managed): Loaded 'System.ServiceModel.Web.dll'
        'UI Task' (Managed): Loaded 'System.ServiceModel.dll'
        The thread '<No Name>' (0x16490a2e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x17630a6a) has exited with code 0 (0x0).
        Log:"report:deviceready"
        The thread '<No Name>' (0x16a507aa) has exited with code 0 (0x0).
        'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
        Log:"onDeviceReady. You should see this message in Visual Studio's output window."
        The thread '<No Name>' (0x173d0dbe) has exited with code 0 (0x0).
        The thread '<No Name>' (0x1731027e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x162a0a4e) has exited with code 0 (0x0).
        Log:"playMP3() counter 0"
        A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
        The thread '<No Name>' (0x16cd082e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x176d0d3a) has exited with code 0 (0x0).
        Log:"playMP32() counter 1"
        The thread '<No Name>' (0x16a808e6) has exited with code 0 (0x0).
        A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
        The thread '<No Name>' (0x179e0852) has exited with code 0 (0x0).




        My Config:
        * cordova : 2.0.0
        * Nokia Lumia 800
        * Version OS : 7.10.8773.98 (commercial : 7.5)

        Microsoft Visual Studio 2010
        Version WPDTRTMRel - 40219.209
        Microsoft .NET Framework
        Version 4.0.30319 SP1Rel
        Installed Version: PD Express



        === 1.8 / (7.10.7740.16) ==
        The MP3 file is only played once (the first time).

        * If I create a new instance of MEDIA each time, the MP3 file is only played once (the first time).

        * If I keep alive the instance (create it in onDeviceReady), I can play multiple time the first mp3 I play. BUT, I cannot play the other mp3.

        note:
        * with version 1.6.1, turn OFF then ON the screen allow you to play one more time the mp3. Not with 1.8.0.
        * same issue with 1.6.1, but the error message are IOException & IsolatedStorageException with various "MEDIA on status" information.


              var playCounter = 0;
              var my_media = null;
              function playMP3(){
                console.log("playMP3()counter " + playCounter);
                if (!(my_media == null)){
                  my_media.release(); //Cordova 1.8.0
                }
                my_media = new Media("app/www/test.mp3");//ressource buildAction == content

                my_media.play();
                playCounter++;
              }

              var my_media2 = null;
                function playMP32(){
                console.log("playMP32() counter " + playCounter);
                if (!(my_media2 == null)){
                  my_media2.release(); //Cordova 1.8.0
                }
                my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
              my_media2.play();
              playCounter++;
              }

            [...]
            <p onclick="playMP3();">Click to Play MP3</p>
            <p onclick="playMP32();">Click to Play MP3 2</p>


        Log:


        Log:"onDeviceReady. You should see this message in Visual Studio's output window."
        'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
        Log:"playMP3() counter 0"
        'UI Task' (Managed): Loaded 'System.SR.dll'
        A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
        Log:"playMP3() counter 1"
        A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
        Dispose :: app/www/test.mp3
        A first chance exception of type 'System.NullReferenceException' occurred in WP7CordovaClassLib.dll
        A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
        Error: El parámetro es incorrecto.
        Log:"playMP32() counter 2"
        INFO: startPlayingAudio could not find mediaPlayer for b5e8e480-de8b-ab2c-82a6-c60270f590f2
        A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
        Error: El parámetro es incorrecto.
        UPDATED with 2.0 and lastest WP7 OS version information (2012-08-09)

        h1. 2.0
        * This is worst on Cordova 2.0.0 : the file is never played.
        * same result with VS configuration Debug and Release.
        * same result while the terminal is connected to Zune and while the terminal is not connected. (I tried this becasue of http://blogs.msdn.com/b/jaimer/archive/2010/11/03/tips-for-debugging-wp7-media-apps-with-wpconnect.aspx)
        * I also tried with a wav file. same result.

        h3. index.html
        {noformat}
        [...]
                <title>Hello Cordova</title>
        <script>
          function MyInit()
          {
          document.getElementById("welcomeMsg").innerHTML += "Cordova is ready! version=" + window.device.cordova;
          console.log("onDeviceReady. You should see this message in Visual Studio's output window.");
          // my_media = new Media("app/www/test.mp3");//ressource buildAction == content
          my_media = new Media("app/www/chord.wav");//ressource buildAction == content; copied from C:\Windows\Media

          my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
          }

          var playCounter = 0;
          var my_media = null;
          function playMP3(){
          console.log("playMP3() counter " + playCounter);
          my_media.play();
          playCounter++;
          }

          var my_media2 = null;
          function playMP32(){
          console.log("playMP32() counter " + playCounter);
          my_media2.play();
          playCounter++;
          }

        </script>

            </head>
            <body>
                <div id="welcomeMsg"></div>
                <div class="app">
                    <h1>Apache Cordova</h1>
                    <div id="deviceready">
                        <p class="status pending blink">Connecting to Device</p>
                        <p class="status complete blink hide">Device is Ready</p>
                    </div>
                </div>
                <script type="text/javascript" src="cordova-2.0.0.js"></script>
                <script type="text/javascript" src="js/index.js"></script>
                <script type="text/javascript">
                    app.initialize();
        </script>

            <p onclick="playMP3();">Click to Play MP3</p>
            <p onclick="playMP32();">Click to Play MP3 2</p>


        </body>
        </html>
        [EOF]
        {noformat}

        h3. index.js
        {noformat}
        [...]
            deviceready: function() {
                // note that this is an event handler so the scope is that of the event
                // so we need to call app.report(), and not this.report()
                app.report('deviceready');
        MyInit();
            },
        [...]
        {noformat}

        h3. output (debug config, terminal connected to Zune):

        {noformat}
        'UI Task' (Managed): Loaded 'System.SR.dll'
        A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
        A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll
        Updating IsolatedStorage for APP:DeviceID :: [edited]
        INFO: Creating Directory :: /app/www
        INFO: Writing data for /app/www\chord.wav and length = 113964
        INFO: Creating Directory :: /app/www\js
        INFO: Writing data for /app/www\js\index.js and length = 792
        INFO: Writing data for /app/www\test.mp3 and length = 34396
        INFO: Writing data for /app/www\test2.mp3 and length = 34396
        INFO: Writing data for /app/www\cordova-2.0.0.js and length = 188657
        INFO: Creating Directory :: /app/www\css
        INFO: Writing data for /app/www\css\index.css and length = 2239
        INFO: Creating Directory :: /app/www\img
        INFO: Writing data for /app/www\img\cordova.png and length = 19932
        INFO: Writing data for /app/www\index.html and length = 1990
        GapBrowser_Navigated :: /app/www/index.html
        'UI Task' (Managed): Loaded 'System.ServiceModel.Web.dll'
        'UI Task' (Managed): Loaded 'System.ServiceModel.dll'
        The thread '<No Name>' (0x16490a2e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x17630a6a) has exited with code 0 (0x0).
        Log:"report:deviceready"
        The thread '<No Name>' (0x16a507aa) has exited with code 0 (0x0).
        'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
        Log:"onDeviceReady. You should see this message in Visual Studio's output window."
        The thread '<No Name>' (0x173d0dbe) has exited with code 0 (0x0).
        The thread '<No Name>' (0x1731027e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x162a0a4e) has exited with code 0 (0x0).
        Log:"playMP3() counter 0"
        A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
        The thread '<No Name>' (0x16cd082e) has exited with code 0 (0x0).
        The thread '<No Name>' (0x176d0d3a) has exited with code 0 (0x0).
        Log:"playMP32() counter 1"
        The thread '<No Name>' (0x16a808e6) has exited with code 0 (0x0).
        A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
        The thread '<No Name>' (0x179e0852) has exited with code 0 (0x0).
        {noformat}


        h3. My Config:
        * cordova : 2.0.0
        * Nokia Lumia 800
        * Version OS : 7.10.8773.98 (commercial : 7.5)
        * Microsoft Visual Studio 2010
        Version WPDTRTMRel - 40219.209
        Microsoft .NET Framework
        Version 4.0.30319 SP1Rel
        Installed Version: PD Express



        h1. 1.8 / (7.10.7740.16)
        The MP3 file is only played once (the first time).

        * If I create a new instance of MEDIA each time, the MP3 file is only played once (the first time).

        * If I keep alive the instance (create it in onDeviceReady), I can play multiple time the first mp3 I play. BUT, I cannot play the other mp3.

        h3. note:
        * with version 1.6.1, turn OFF then ON the screen allow you to play one more time the mp3. Not with 1.8.0.
        * same issue with 1.6.1, but the error message are IOException & IsolatedStorageException with various "MEDIA on status" information.


        {noformat}
              var playCounter = 0;
              var my_media = null;
              function playMP3(){
                console.log("playMP3()counter " + playCounter);
                if (!(my_media == null)){
                  my_media.release(); //Cordova 1.8.0
                }
                my_media = new Media("app/www/test.mp3");//ressource buildAction == content

                my_media.play();
                playCounter++;
              }

              var my_media2 = null;
                function playMP32(){
                console.log("playMP32() counter " + playCounter);
                if (!(my_media2 == null)){
                  my_media2.release(); //Cordova 1.8.0
                }
                my_media2 = new Media("app/www/test2.mp3");//ressource buildAction == content
              my_media2.play();
              playCounter++;
              }

            [...]
            <p onclick="playMP3();">Click to Play MP3</p>
            <p onclick="playMP32();">Click to Play MP3 2</p>
        {noformat}

        h3. Log:

        {noformat}
        Log:"onDeviceReady. You should see this message in Visual Studio's output window."
        'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
        Log:"playMP3() counter 0"
        'UI Task' (Managed): Loaded 'System.SR.dll'
        A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
        Log:"playMP3() counter 1"
        A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
        Dispose :: app/www/test.mp3
        A first chance exception of type 'System.NullReferenceException' occurred in WP7CordovaClassLib.dll
        A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
        Error: El parámetro es incorrecto.
        Log:"playMP32() counter 2"
        INFO: startPlayingAudio could not find mediaPlayer for b5e8e480-de8b-ab2c-82a6-c60270f590f2
        A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
        Error: El parámetro es incorrecto.
        {noformat}
        Jesse MacFadyen made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Jesse MacFadyen added a comment -

        https://github.com/purplecabbage/incubator-cordova-wp7/commit/86611cd1e07f72f19e01396f0ea067ae363b2467

        Note that WP7+Silverlight only supports 1 MediaElement at a time, so there cannot be overlapping sounds in the current implementation.

        Show
        Jesse MacFadyen added a comment - https://github.com/purplecabbage/incubator-cordova-wp7/commit/86611cd1e07f72f19e01396f0ea067ae363b2467 Note that WP7+Silverlight only supports 1 MediaElement at a time, so there cannot be overlapping sounds in the current implementation.
        Jesse MacFadyen made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Jesse MacFadyen
            Reporter:
            Christophe A. Guilmart
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development