Ejemplo n.º 1
0
        /// <summary>
        /// Pauses playing
        /// </summary>
        public void pausePlayingAudio(string options)
        {
            MediaOptions mediaOptions;

            try
            {
                mediaOptions = JSON.JsonHelper.Deserialize <MediaOptions>(options);
            }
            catch (Exception)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
                return;
            }

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                try
                {
                    if (Media.players.ContainsKey(mediaOptions.Id))
                    {
                        AudioPlayer audio = Media.players[mediaOptions.Id];
                        audio.pausePlaying();
                    }

                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
                }
                catch (Exception e)
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
                }
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Pauses playing
        /// </summary>
        public void pausePlayingAudio(string options)
        {
            try
            {
                string mediaId = JSON.JsonHelper.Deserialize <string[]>(options)[0];

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        if (Media.players.ContainsKey(mediaId))
                        {
                            AudioPlayer audio = Media.players[mediaId];
                            audio.pausePlaying();
                        }
                        else
                        {
                            Debug.WriteLine("ERROR: pausePlayingAudio could not find mediaPlayer for " + mediaId);
                        }

                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
                    }
                    catch (Exception e)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
                    }
                });
            }
            catch (Exception)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
            }
        }