How do you get/set media volume (not ringtone volume) in Android?

private AudioManager audio; Inside onCreate: audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); Override onKeyDown: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); return true; default: return false; } }

Embedding Windows Media Player for all browsers

The following works for me in Firefox and Internet Explorer: <object id=”mediaplayer” classid=”clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95″ codebase=”http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701″ standby=”loading microsoft windows media player components…” type=”application/x-oleobject” width=”320″ height=”310″> <param name=”filename” value=”https://stackoverflow.com/questions/164/./test.wmv”> <param name=”animationatstart” value=”true”> <param name=”transparentatstart” value=”true”> <param name=”autostart” value=”true”> <param name=”showcontrols” value=”true”> <param name=”ShowStatusBar” value=”true”> <param name=”windowlessvideo” value=”true”> <embed src=”https://stackoverflow.com/questions/164/./test.wmv” autostart=”true” showcontrols=”true” showstatusbar=”1″ bgcolor=”white” width=”320″ height=”310″> </object>

How to bind dynamic content using ?

Like as in <p:graphicImage>, the value attribute can point to a bean property returning StreamedContent. This only requires a special getter method for the reasons which is explained in detail in the following answer on using <p:graphicImage> with a dynamic resource from a database: Display dynamic image from database with p:graphicImage and StreamedContent. In your … Read more

Using cache in ExoPlayer

Here is the solution for ExoPlayer 2.+ Create a custom cache data source factory public class CacheDataSourceFactory implements DataSource.Factory { private final Context context; private final DefaultDataSourceFactory defaultDatasourceFactory; private final long maxFileSize, maxCacheSize; public CacheDataSourceFactory(Context context, long maxCacheSize, long maxFileSize) { super(); this.context = context; this.maxCacheSize = maxCacheSize; this.maxFileSize = maxFileSize; String userAgent = Util.getUserAgent(context, … Read more

Scan Android SD card for new files

I’ve tried plenty of different methods to trigger the MediaScanner, and these are my results. SendBroadcast The most simple and naive solution. It consists in executing the following instruction from your code: sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse(“file://”+ Environment.getExternalStorageDirectory()))); However, this no longer works in KitKat devices, due to a lack of required permissions. MediaScannerWrapper As posted here … Read more

Play sound using soundpool example

Create a folder named as raw under your_app/res/. Then paste your ringtone in this folder, for example your_app/res/raw/ringtone.mp3. Now use the following code: SoundPool soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); int soundId = soundPool.load(context, R.raw.ringtone, 1); // soundId for reuse later on soundPool.play(soundId, 1, 1, 0, 0, 1); Be sure to release the SoundPool resources … Read more

Playing BG Music Across Activities in Android

You can also create a service which play music using mediaplayer as below. Intent svc=new Intent(this, BackgroundSoundService.class); startService(svc); //OR stopService(svc); public class BackgroundSoundService extends Service { private static final String TAG = null; MediaPlayer player; public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { super.onCreate(); player = MediaPlayer.create(this, R.raw.idil); player.setLooping(true); // … Read more

How to use Blob URL, MediaSource or other methods to play concatenated Blobs of media fragments?

There is currently no Web API targeted to video editing. The MediaStream and MediaRecorder APIs are meant to deal with live sources. Because of the structure of video files, you can’t just slice a part of it to make a new video, nor can you just concatenate small video files to make one longer. In … Read more

Do iPhone / Android browsers support CSS @media handheld?

You can use @media queries: <link rel=”stylesheet” href=”https://stackoverflow.com/questions/3893342/path/to/iphone.css” media=”only screen and (max-device-width:480px)”/> This particular version will target the iPhone (and any other device with a screen of max-device-width of 480px. Apple, for the iPhone, though this is from memory so I can’t be entirely sure of its accuracy, chose to disregard the use of handheld … Read more