lunedì 29 novembre 1999

LG KE970 Shine bug using MediaPlayer and setVolume

If you want to set the volume in the MediaPlayer using the following code:



                InputStream is = getClass().getResourceAsStream( "/sound.amr" );

                Player player = Manager.createPlayer(is, soundType);

               
player.addPlayerListener( this );

               
player.realize();

                VolumeControl volumeControl =

                (VolumeControl)
player .getControl( "VolumeControl" );

                if ( volumeControl != null ) {

                    volumeControl.setLevel( volume );

                }



when you launch the player with:



                player.start();



no sound can be heard on the LG KE970 Shine without getting any error.



This device requires to get the prefetched status if you want to set the volume and play the sound correctly. The working code is then:





                InputStream is = getClass().getResourceAsStream( "/sound.amr" );

                Player player = Manager.createPlayer(is, soundType);

               
player.addPlayerListener( this );

               
player.realize();

               
player.prefetch( );

                VolumeControl volumeControl =

                (VolumeControl)
player .getControl( "VolumeControl" );

                if ( volumeControl != null ) {

                    volumeControl.setLevel( volume );

                }




Maybe other phones are affected as well (especially LG). Post comment if you other phones with the same problem.

Nessun commento:

Posta un commento