<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>sound &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/sound/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Tue, 09 Nov 2010 08:04:45 +0000</lastBuildDate>
	<language>en-GB</language>
	<copyright>© Terence Eden. 🄯 CC BY-SA. See https://shkspr.mobi/blog/copyright-and-copyleft/</copyright>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>sound &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[HOWTO: Android Audio Widget]]></title>
		<link>https://shkspr.mobi/blog/2010/11/howto-android-audio-widget/</link>
					<comments>https://shkspr.mobi/blog/2010/11/howto-android-audio-widget/#comments</comments>
				<dc:creator><![CDATA[Terence Eden]]></dc:creator>
		<pubDate>Tue, 09 Nov 2010 08:04:45 +0000</pubDate>
		<category><![CDATA[android]]></category><category><![CDATA[NaBloPoMo]]></category><category><![CDATA[sound]]></category><category><![CDATA[widget]]></category>		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=2650</guid>

					<description><![CDATA[I&#039;ve recently released a couple of audio widgets.  Inspired by the Instant Rimshot and Sad Trombone sites, these are &#34;single serving&#34; widget.  For the &#34;Family Fortunes&#34; buzzer widget, you click the icon and you&#039;ll hear the famous &#34;EURGH-ERRRR&#34; noise.  I&#039;m also selling a &#34;Dramatic Sound Effect&#34; Widget - download it by scanning this code.  Go on, it&#039;s a mere 50p!   This is a quick tutorial showing…]]></description>
										<content:encoded>&lt;p&gt;I've recently released a couple of audio widgets.  Inspired by the &lt;a href="http://instantrimshot.com/"&gt;Instant Rimshot&lt;/a&gt; and &lt;a href="http://www.sadtrombone.com/"&gt;Sad Trombone&lt;/a&gt; sites, these are "&lt;a href="http://kottke.org/08/02/single-serving-sites"&gt;single serving&lt;/a&gt;" widget.&lt;/p&gt;

&lt;p&gt;For the "Family Fortunes" buzzer widget, you click the icon and you'll hear the famous "EURGH-ERRRR" noise.&lt;/p&gt;

&lt;p&gt;I'm also selling a "Dramatic Sound Effect" Widget - download it by scanning this code.  Go on, it's a mere 50p!
&lt;img src="https://shkspr.mobi/blog/wp-content/uploads/2010/11/Dramatic-Widget-QR-Code.png" alt="Dramatic Widget QR Code" title="Dramatic Widget QR Code" width="150" height="150" class="aligncenter size-full wp-image-2857"&gt;&lt;/p&gt;

&lt;p&gt;This is a quick tutorial showing how to build a sound playing widget in Android.  It assumes you've already set up Eclipse and know how to create your own projects.&lt;/p&gt;

&lt;h2 id="the-source-code"&gt;&lt;a href="https://shkspr.mobi/blog/2010/11/howto-android-audio-widget/#the-source-code"&gt;The Source Code&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Here's the main Java source code - with comments.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;package mobi.shkspr.android.ButtonWidget;

import mobi.shkspr.android.ButtonWidget.R;

//All the Androidy bits and bobs you need to import.
import android.media.*;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class ButtonWidget extends AppWidgetProvider {
    public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget";

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        //First up, the icon. I've created a file called h_yellow_x.png and placed it in /res/drawable
                int drawableResourse = R.drawable.h_yellow_x;
                //Set Up the widget
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
                //Set the image which will appear on the screen
        remoteViews.setImageViewResource(R.id.ImageView01, drawableResourse );
        Intent active = new Intent(context, ButtonWidget.class);
        active.setAction(ACTION_WIDGET_RECEIVER);
        PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0);
        remoteViews.setOnClickPendingIntent(R.id.ImageView01, actionPendingIntent);
        appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        // v1.5 fix that doesn't call onDelete Action
        final String action = intent.getAction();
        if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
            //The widget is being deleted off the desktop
            final int appWidgetId = intent.getExtras().getInt(
                    AppWidgetManager.EXTRA_APPWIDGET_ID,
                    AppWidgetManager.INVALID_APPWIDGET_ID);
            if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
                this.onDeleted(context, new int[] { appWidgetId });
            }
        } else {
            // check, if our Action was called
            if (intent.getAction().equals(ACTION_WIDGET_RECEIVER)) {

                //Play the audio file
                                //The audio file is in /res/raw/ and is an OGG file
                MediaPlayer mPlay = MediaPlayer.create(context, R.raw.ff);
                mPlay.start();
            } else {
                // do nothing
            }


            super.onReceive(context, intent);
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Also&lt;/p&gt;

&lt;h2 id="the-manifest"&gt;&lt;a href="https://shkspr.mobi/blog/2010/11/howto-android-audio-widget/#the-manifest"&gt;The Manifest&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;The XML you'll need to get everything configured.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mobi.shkspr.android.ButtonWidget"
    android:versionCode="1"
    android:versionName="1.0"&amp;gt;

    &amp;lt;application android:icon="@drawable/icon" android:label="@string/app_name"&amp;gt;

        &amp;lt;!-- Broadcast Receiver that will process AppWidget updates --&amp;gt;
        &amp;lt;receiver android:name=".ButtonWidget" android:label="@string/app_name"&amp;gt;
            &amp;lt;intent -filter&amp;gt;
                &amp;lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&amp;gt;
                &amp;lt;!-- Broadcast Receiver that will also process our self created action --&amp;gt;
                &amp;lt;action android:name="my.package.name.ButtonWidget.ACTION_WIDGET_RECEIVER"/&amp;gt;
            &amp;lt;/intent&amp;gt;
            &amp;lt;meta -data android:name="android.appwidget.provider" android:resource="@xml/widget_def" /&amp;gt;
        &amp;lt;/receiver&amp;gt;

    &amp;lt;/application&amp;gt;

    &amp;lt;uses -sdk android:minSdkVersion="3" /&amp;gt;
&amp;lt;/manifest&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=2650&amp;amp;HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager"&gt;</content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2010/11/howto-android-audio-widget/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
