cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benn Mapes (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-1593) WP7 : Media callback called multiple times
Date Fri, 25 Jan 2013 00:47:12 GMT

    [ https://issues.apache.org/jira/browse/CB-1593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13562223#comment-13562223
] 

Benn Mapes commented on CB-1593:
--------------------------------

I was able to fix both the bugs and will make a pull request.

The first one I fixed by changing a line in Media.cs from:

Media.players.Add(mediaOptions.Id, audio);
to
Media.players[mediaOptions.Id] = audio;

in the startPlayingAudio(....) method. This prevents a random 'ArgumentExeception' that happens
sometimes (maybe 1 in 5) on the first execution of an audio file.

The second bug with the multiple callbacks took me a while to track down but it appeared that
Events in NativeExecution.cs were persisting and more and more BaseCommands were getting created
but not being taken away by garbage collection so each time an event fired it also triggered
all the old ones as well and they would build up. I fixed this by removing any old events
from the baseCommand before adding new ones so the lines I changed went from,
bc.OnCommandResult += OnCommandResultHandler;
bc.OnCustomScript += OnCustomScriptHandler;
to
bc.OnCommandResult -= OnCommandResultHandler;
bc.OnCommandResult += OnCommandResultHandler;
bc.OnCustomScript -= OnCustomScriptHandler;
bc.OnCustomScript += OnCustomScriptHandler;

which solved the multiple callbacks.

Let me know if there are any related problems or if these additions caused any regressions.


                
> WP7 : Media callback called multiple times
> ------------------------------------------
>
>                 Key: CB-1593
>                 URL: https://issues.apache.org/jira/browse/CB-1593
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: WP7
>    Affects Versions: 2.1.0
>         Environment: Nokia Lumia 800 with WP 7.5 (7.10.8773.98).
>            Reporter: Christophe A. Guilmart
>            Assignee: Benn Mapes
>            Priority: Critical
>
> When using this code
>           function play(){
>             cordovaMedia = new Media("app/www/test.mp3", onSuccess, onError, onStatus);
>             cordovaMedia.play();
> 		  }
> 		  
> I encounter the following problems:
> * 1st call to play() does not work (ie: I don't hear the sound). nor are the callback
called.
> * following play work, but callback are called multiple times.
> * onError is called even when play sound is successful (ie: when I can hear the sound).
> * if onStatus callback is not provided, an error show up in the log.
> Expected behavior:
> * onError & onSuccess should be exclusive. One OR the other should be called. Not
both.
> * onError & onSuccess should be called only once per call to .play()
> h3. VS Output:
> Log:"Received Event: deviceready"
> Log:"----------------------------------"
> Log:"# media play 0"
> 'UI Task' (Managed): Loaded 'Microsoft.Xna.Framework.dll'
> 'UI Task' (Managed): Loaded 'System.SR.dll'
> Log:"----------------------------------"
> Log:"# media play 1"
> Log:"####### media On Error. error: Value does not fall within the expected range. code:
undefined message: undefined"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"----------------------------------"
> INFO: startPlayingAudio FOUND mediaPlayer for b43e2cd0-bafb-f6d3-add6-79428f19e324
> Log:"# media play 2"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"----------------------------------"
> Log:"# media play 3"
> Log:"####### media On Error. error: Value does not fall within the expected range. code:
undefined message: undefined"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 1"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media OnStatus: 2"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> Log:"# media OnStatus: 4"
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media On success. "
> Log:"# media OnStatus: 4"
> h3. index.html
> [...]
>         <script type="text/javascript">
>           app.initialize();
>           function onError (error){
>           var s = "####### media On Error. ";
>           if ((typeof error === "undefined") || (error==null)){
>           s = s + " no error info."
>           } else {
>           s = s +  "error: " + error +
>           ' code: '    + error.code    +
>           ' message: ' + error.message;
>           }
>           console.log(s);
>           }
>           function onSuccess (){
>           var s = "# media On success. ";
>           console.log(s);
>           }
>           function onStatus (status){
>           var s = "# media OnStatus: " + status;
>           console.log(s);
>           }
>           var playcounter = 0;
>           function play(){
>           console.log("----------------------------------");
>           var s = "# media play " + playcounter;
>           console.log(s);
>           cordovaMedia = new Media("app/www/test.mp3", onSuccess, onError, onStatus);
>           cordovaMedia.play();
>           playcounter++;
>           }
>         </script>
>       <p onclick="play();">Click to Play MP3</p>
>       
>     </body>
> </html>
> h3. My Config:
> * cordova : 2.1.0-0-g26d211b
> * template "full"
> * 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

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message