Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
     
            /*
            var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            path = System.IO.Path.Combine(path, "loop_stereo.aif"); // loop_mono.wav
            if (!System.IO.File.Exists(path))
                throw new ArgumentException("file not found; " + path);*/

            var url = MonoTouch.CoreFoundation.CFUrl.FromFile("loop_stereo.aif");
            _player = new ExtAudioFilePlayer(url);

            // setting audio session
            _slider.ValueChanged += new EventHandler(_slider_ValueChanged);
            _playButton.TouchDown += new EventHandler(_playButton_TouchDown);
            _stopButton.TouchDown += new EventHandler(_stopButton_TouchDown);

            _slider.MaxValue = _player.TotalFrames;

            _isTimerAvailable = true;
            _timer = NSTimer.CreateRepeatingTimer(TimeSpan.FromMilliseconds(100),
                delegate {
                    if (_isTimerAvailable)
                    {
                        long pos = _player.CurrentPosition;
                        _slider.Value = pos;
                        //System.Diagnostics.Debug.WriteLine("CurPos: " + _player.CurrentPosition.ToString());
                    }                    
                }
                );
            NSRunLoop.Current.AddTimer(_timer, "NSDefaultRunLoopMode");            
        }
Ejemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            /*
             * var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
             * path = System.IO.Path.Combine(path, "loop_stereo.aif"); // loop_mono.wav
             * if (!System.IO.File.Exists(path))
             *  throw new ArgumentException("file not found; " + path);*/

            var url = MonoTouch.CoreFoundation.CFUrl.FromFile("loop_stereo.aif");

            _player = new ExtAudioFilePlayer(url);

            // setting audio session
            _slider.ValueChanged  += new EventHandler(_slider_ValueChanged);
            _playButton.TouchDown += new EventHandler(_playButton_TouchDown);
            _stopButton.TouchDown += new EventHandler(_stopButton_TouchDown);

            _slider.MaxValue = _player.TotalFrames;

            _isTimerAvailable = true;
            _timer            = NSTimer.CreateRepeatingTimer(TimeSpan.FromMilliseconds(100),
                                                             delegate {
                if (_isTimerAvailable)
                {
                    long pos      = _player.CurrentPosition;
                    _slider.Value = pos;
                    //System.Diagnostics.Debug.WriteLine("CurPos: " + _player.CurrentPosition.ToString());
                }
            }
                                                             );
            NSRunLoop.Current.AddTimer(_timer, "NSDefaultRunLoopMode");
        }