Анимация рисовать со звуком в Android? - PullRequest
1 голос
/ 05 апреля 2011

Я использую анимацию в моем классе.

Мне нужно генерировать звук при загрузке каждого кадра анимации. Возможно это или нет. Я использую следующий код для анимации:

<?xml version="1.0" encoding="utf-8"?>
<animation-list   android:id="@+id/handimation" android:oneshot="false" 
    xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:drawable="@drawable/count3" android:duration="650" />
    <item android:drawable="@drawable/count2" android:duration="650" />
     <item android:drawable="@drawable/count1" android:duration="650" />
     <item android:drawable="@drawable/go" android:duration="650" />
 </animation-list> 

Моя Java:

AnimationDrawable frameAnimation;
         ImageView animatedimage ;
animatedimage = (ImageView)findViewById(R.id.rcount);
              final MyAnimationRoutineStart animationStart = 
                                          new MyAnimationRoutineStart();
              final MyAnimationRoutineStop animationStop = 
                                           new MyAnimationRoutineStop();
animatedimage.setBackgroundResource(R.drawable.spin);
frameAnimation = (AnimationDrawable) animatedimage.getBackground();
Timer animateTimerStart = new Timer(false);
animateTimerStart.schedule(animationStart, 100);
Timer animateTimerStop = new Timer(false);
animateTimerStop.schedule(animationStop, 2500);

class MyAnimationRoutineStart extends TimerTask
        {
            MyAnimationRoutineStart()
            {

            }
            public void run()
            {
            // Start the animation (looped playback by default).
                frameAnimation.start();


            }
        }

        class MyAnimationRoutineStop extends TimerTask
        {
            MyAnimationRoutineStop()
            {       
            }

            public void run()
            {
            frameAnimation.stop();
            // stop the animation (looped playback by default).

            videoName=camcorderView.startRecording();
            counter = 0;
            counterFlag = true;
            counterThread.start();


            }
          }

Я не знаю, где генерировать звук.

Любой предлагает идею.

Спасибо.

1 Ответ

0 голосов
/ 19 апреля 2011

Я добился этого с помощью обработчика. Внутри обработчика я запускаю и воспроизводю звук и задерживаю сообщение обработчика на время каждого кадра анимации. Работает нормально.

...