tag:blogger.com,1999:blog-66834012322738612072024-02-21T01:27:36.771-08:00blackberry Development GuideParwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-6683401232273861207.post-81053297054288747222012-07-30T01:05:00.003-07:002012-07-30T01:05:24.748-07:00Blackberry Play Multimedia<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/w6fbR65lpwQ" width="420"></iframe>Parwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.com0tag:blogger.com,1999:blog-6683401232273861207.post-4992308351638826682012-02-03T02:55:00.000-08:002012-02-03T03:01:28.357-08:00Splash ScreenKebiasaan sebuah aplikasi entah itu aplikasi yang berbasi java atau lainnya, menggunakan splash screen sebagai tampilan pertama untuk memperlihatkan logo atau pengenalan sebuah aplikasi, dalam tutorial ini saya akan coba jelaskan proses pembuatan splash screen pada aplikasi blackberry.<br />
<br />
Contoh detail script splash screen :<br />
<div style="text-align: justify;"></div><blockquote><div style="text-align: left;">package mainapp;</div><div style="text-align: left;">import java.util.Timer;</div><div style="text-align: left;">import java.util.TimerTask;</div><div style="text-align: left;">import utils.AnimatedGIFField;</div><div style="text-align: left;">import utils.GraphicUtil;</div><div style="text-align: left;">import net.rim.device.api.notification.NotificationsConstants;</div><div style="text-align: left;">import net.rim.device.api.notification.NotificationsManager;</div><div style="text-align: left;">import net.rim.device.api.system.Bitmap;</div><div style="text-align: left;">import net.rim.device.api.system.Display;</div><div style="text-align: left;">import net.rim.device.api.system.EncodedImage;</div><div style="text-align: left;">import net.rim.device.api.system.GIFEncodedImage;</div><div style="text-align: left;">import net.rim.device.api.ui.Color;</div><div style="text-align: left;">import net.rim.device.api.ui.Graphics;</div><div style="text-align: left;">import net.rim.device.api.ui.Manager;</div><div style="text-align: left;">import net.rim.device.api.ui.UiApplication;</div><div style="text-align: left;">import net.rim.device.api.ui.container.MainScreen;</div><div style="text-align: left;">public final class SplashScreen extends MainScreen</div><div style="text-align: left;">{</div><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>private int _width;</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>private int _height;</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>private Bitmap splashImage;</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>private int offsetY;</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>private GIFEncodedImage _waitImage;</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>private AnimatedGIFField _waitField;</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>private int offsetYWait;</div></span><div style="text-align: left;"> public SplashScreen()</div><div style="text-align: left;"> {</div><div style="text-align: left;">EncodedImage backgroundImage = EncodedImage.getEncodedImageResource(Const.splasScreenImage);</div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>_waitImage = Const.getLargeLoadAnimation();</div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>SplashManager manager = new SplashManager(0);</div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>_waitField = new AnimatedGIFField(_waitImage);</div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>manager.add(_waitField);</div><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>add(manager);</div></span><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>_width = Display.getWidth();</div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>_height = Display.getHeight();</div><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span></div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>int ratiow = 100 * _width / backgroundImage.getWidth();</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>int desiredHeight = backgroundImage.getHeight() * ratiow / 100;</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span></div></span><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>splashImage = GraphicUtil.resizeBitmap(backgroundImage, _width, desiredHeight);</div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>offsetY = (_height - splashImage.getHeight()) >> 1;</div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>int splashY = _height - (_height / 4);</div><div style="text-align: left;"> offsetYWait = splashY - (_waitField.getHeight() / 2); </div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span></div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>final Timer timer = new Timer();</div><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>TimerTask tt = new TimerTask(){</div><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span> public void run() {</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span> <span class="Apple-tab-span"> </span>timer.cancel();</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span> <span class="Apple-tab-span"> </span>UiApplication.getUiApplication().invokeLater(new Runnable() { </div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span> public void run(){</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span> <span class="Apple-tab-span"> </span> UiApplication.getUiApplication().pushScreen(new Login());</div></span><div style="text-align: left;"> <span class="Apple-tab-span" style="white-space: pre;"> </span> close();</div><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span> }</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span> });</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span> }</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>};</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>timer.schedule(tt, 3000, 3000);</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>Object theSource = new Object() {</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>public String toString() {</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>return Const.nulinesProfileName;</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>}</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>};</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>NotificationsManager.registerSource(Const.notificationId,</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>theSource, NotificationsConstants.IMPORTANT);</div></span><div style="text-align: left;"> }</div><div style="text-align: left;"> private final class SplashManager extends Manager </div><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>{</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>public SplashManager(long style)</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>{</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>super(style);</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>}</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>protected void paintBackground(Graphics graphics)</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>{</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>graphics.setColor(Color.BLACK);</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>graphics.fillRect(0, 0, _width, _height);</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>if (splashImage != null){</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>graphics.drawBitmap(0, offsetY, splashImage.getWidth(), splashImage.getHeight(), splashImage, 0, 0);</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>}</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>super.paintBackground(graphics);<span class="Apple-tab-span"> </span></div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>}</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>protected void sublayout(int width, int height) {</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>layoutChild(_waitField, width, height);</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>setPositionChild(_waitField, (width - _waitField.getWidth()) >> 1, offsetYWait);</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>setExtent(Display.getWidth(), Display.getHeight());</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>}</div></span><span class="Apple-tab-span" style="white-space: pre;"><div style="text-align: left;"><span class="Apple-tab-span"> </span>}</div></span><div style="text-align: left;">}</div></blockquote>Parwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.com0tag:blogger.com,1999:blog-6683401232273861207.post-75736505270423455892012-02-03T02:31:00.000-08:002012-02-03T02:44:31.740-08:00Supported Media Types on BlackBerry Smartphones<div style="text-align: justify;">In the Media application on the BlackBerry® smartphone, you can open media files such as videos, ring tones, pictures, and songs that are stored on the BlackBerry smartphone built-in media storage, application storage, or on a media card.</div><div style="text-align: justify;">The following tables list the codecs that are recommended and the codecs that are supported for video formats and audio formats on BlackBerry smartphones, as well as whether RTSP streaming is supported using that file format.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><a href="http://www.ziddu.com/download/18498176/Supported-Media-Types-on-BlackBerry-Smartphones.pdf.html" target="_blank">click this link to get all explanation about supported media type</a></div>Parwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.com0tag:blogger.com,1999:blog-6683401232273861207.post-35384211309153359402012-02-03T02:22:00.000-08:002012-02-03T02:23:10.453-08:00<div style="text-align: justify;"><b>C10 Audio And Video Playback</b></div><div style="text-align: justify;"><br />
This tutorial will show you how to play audio and video files in your application. I will show you how to use the Mobile Media API (MMAPI), also known as JSR 135 on BlackBerry SmartPhones.</div><div style="text-align: justify;">I will guide you through the MMAPI, then show you on example on how to play simple tunes, how to play music from file bundled with the application, and how to play the file from your SD card.</div><div style="text-align: justify;">I will also tell you which files are supported and how to implement PlayerListener to track events like when the song has finished.</div><div style="text-align: justify;">Then we will cover the video playback. I will show you how to play video in full screen and non-full screen modes.</div><div style="text-align: justify;"><b><br />
</b><br />
<b>Audio Playback</b></div><div style="text-align: justify;"><br />
To play audio on BlackBerry SmartPhones, we will use classes and interfaces from the <i>javax.microedition.media</i> package. This package is fully compatible with the MMAPI (JSR 135) and if you already have knowledge on how to use it, you can start using it straight away.</div><div style="text-align: justify;">Let’s start with an overview of the Manager class.</div><div style="text-align: justify;"><b><br />
</b><br />
<b>Manager Class</b></div><div style="text-align: justify;"><br />
If you did not notice already there are two classes called Manager in the BlackBerry APIs. The first class is called javax.microedition.media.Manager and the other one is net.rim.device.api.ui.Manager. The first one is the one used for media handling and the latter one is used for managing the UI components of the screen. It is worth paying attention when importing packages.</div><div style="text-align: justify;">The Manager class was introduced in version 4.0.0 of BlackBerry JDE. We need the Manager to get access to system resources such as the Player for multimedia processing.</div><div style="text-align: justify;">So first thing the Manager does is create a Player which we use to play our media files.</div><div style="text-align: justify;">But it can also be used to query a Player, what controls it supports, i.e. volume controls as well as supported content types and protocols. It can be also used to play single tones.</div><div style="text-align: justify;"><b><br />
</b><br />
<b>Content Types and Protocols</b></div><div style="text-align: justify;"><br />
Content types indentify the type of media. They are also registered as MIME types.</div><div style="text-align: justify;">Common audio content types are:</div><div style="text-align: justify;">Wave audio files: audio/x-wav, usually files with extension .wav</div><div style="text-align: justify;">MP3 audio files: audio/mpeg, usually files with extension .mp3</div><div style="text-align: justify;">MIDI audio files: audio/midi, usually files with extension .midi</div><div style="text-align: justify;">To find our which protocols specific content types support on the device we can use:</div><div style="text-align: justify;"><span style="color: cyan;">public static String[] getSupportedProtocols(String content_type).</span></div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">You can also use:</div><div style="text-align: justify;"><span style="color: cyan;">public static String[] getSupportedContentTypes(String protocol),</span></div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">to find out which content types specific protocols support.</div><div style="text-align: justify;"><b><br />
</b><br />
<b>Playing Single Tones</b></div><div style="text-align: justify;"><br />
To play a single tone you can use:</div><div style="text-align: justify;"><span style="color: cyan;">public static void playTone(int note, int duration, int volume)</span></div><div style="text-align: justify;"><span style="color: cyan;">throws MediaException</span></div><div style="text-align: justify;">where:</div><div style="text-align: justify;">• SEMITONE_CONST = 17.31234049066755 = 1/(ln(2^(1/12)))</div><div style="text-align: justify;">• note = ln(freq/8.176)*SEMITONE_CONST</div><div style="text-align: justify;">• The musical note A = MIDI note 69 (0x45) = 440 Hz</div><div style="text-align: justify;">• duration is note duration in milliseconds, and</div><div style="text-align: justify;">• volume is in range from 0 to 100.</div><div style="text-align: justify;">We can use ToneControl constants to play a single note to make our life a little bit easier:</div><div style="text-align: justify;"><span style="color: cyan;">try {</span></div><div style="text-align: justify;"><span style="color: cyan;">Manager.playTone(ToneControl.C4, 1000, 100);</span></div><div style="text-align: justify;"><span style="color: cyan;">} catch (MediaException e) { }</span></div><div style="text-align: justify;">This will play middle C note for 1 second at full volume.</div><div style="text-align: justify;"><b><br />
</b><br />
<b>Creating a Player</b></div><div style="text-align: justify;"><br />
To create a player which will play our audio files we use the following:</div><div style="text-align: justify;"><span style="color: cyan;">Player Manager.createPlayer(String url);</span></div><div style="text-align: justify;">Where url is the location of the audio file. It can be bundled with the application or located on the</div><div style="text-align: justify;">device’s memory or SD card.</div><div style="text-align: justify;"><b><br />
</b><br />
<b>Player Class</b></div><div style="text-align: justify;"><br />
Player has a life cycle. It has 5 states: unrealized, realized, prefetched, started and closed.</div><div style="text-align: justify;">Once you create a player it is in the unrealized state. Once it is created it tries to connect to the source of the audio. When the system finds the source (which can be time consuming – especially when using the network) it moves the player in realized state.</div><div style="text-align: justify;">The Prefetched state is when the player is ready to play audio. From start the player and it enters the end it will move back to the prefetched state. It is important to know you cannot call some methods in some states. It makes no sense for example to call method start(); to start playback unrealized, realized or closed state. </div><div style="text-align: justify;">methods which we can call to get from one state into another.</div><div style="text-align: justify;"><b><br />
</b><br />
<b>Playing Audio</b></div><div style="text-align: justify;"><br />
To play audio in your application you might first want to choose which format to use. For background instrumental music, MIDI is the best format as the file sizes are very small, typically 10 - 20 kb, and the sound quality is very good. However if you want to have vocals, or just voice, or any other sound effects, such as thunder or explosions, you will probably choose Mp3.</div><div style="text-align: justify;">Mp3 files are bigger, but you can reduce sample rates, to create smaller files, at cost of quality.</div><div style="text-align: justify;">Here is a code sample which opens a midi file called test.mid:</div><blockquote class="tr_bq"><span style="background-color: #cccccc;">import java.io.InputStream;<br />
import javax.microedition.media.*;<br />
import javax.microedition.media.control.*;.<br />
public Player myPlayer;<br />
public VolumeControl vc;.</span></blockquote><div style="text-align: justify;">and more... <a href="http://www.ziddu.com/download/18497998/Blackberry_Audio_And_Video_Playback.pdf.html" target="_blank">click this to get more explanation</a></div>Parwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.com0tag:blogger.com,1999:blog-6683401232273861207.post-78322230912458818312012-02-03T02:00:00.000-08:002012-02-03T02:00:48.667-08:00BlackBerry Java Application Multimedia<b><span style="font-size: x-large;">Working with multimedia in a BlackBerry device application</span></b><br />
<span style="font-size: large;"><b>Creating a BlackBerry device application that plays media</b></span><br />
<br />
<div style="text-align: justify;">You can create a BlackBerry® device application that plays media in the BlackBerry® Browser or in the Media application on a BlackBerry device. A BlackBerry device media application can also be created to play audio, video, and binary SVG content. A BlackBerry device application can also be created to record audio and video, and send audio to a Bluetooth® enabled headset.</div><br />
<div style="text-align: justify;">The Content Handler API, is also used to provide an execution model for remotely invoking non-core BlackBerry device applications. CHAPI is an ideal mechanism for setting invocation parameters for non-core BlackBerry device applications. Using CHAPI, you can invoke applications by providing either a URL, content type, or content ID when using one of the constructors available in <i>javax.microedition.content.Invocation class</i>.</div><br />
<div style="text-align: justify;">You can create a BlackBerry device application to play media that uses the Player interface and the javax.microedition.media package. The Player interface has been implemented by RIM. It provides the methods needed to manage the different states of a BlackBerry device application that plays media and control the playback of media files.</div><div style="text-align: justify;"></div>A Player object is first constructed in an UNREALIZED state. While in this state the object is incapable of doing anything for lack of information and resources.<br />
<br />
Invoking realize() will move the Player into a REALIZED state. This enables the Player to locate information to get the basic resources to play a media file.<br />
<br />
Invoking prefetch() will move the Player into a PREFETCHED state. In this state the Player obtains necessary resources, and then “fetches” some of the media file to immediately start playback as soon as the Player has been started.<br />
Invoking start() will move the Player into a STARTED start where the Player starts immediate playback of media.<br />
<br />
It is possible to invoke start() without invoking realize() and prefetch(). The start() method will invoke prefetch<br />
(0), which invokes realize() before media playback can be started. The simplicity of using start() in this manner may be offset through increased delays starting media playback.<br />
<b>Create a BlackBerry device application that plays media</b><br />
<br />
<ol><li>Import the required classes.</li>
</ol><div><blockquote class="tr_bq"><span style="background-color: #cccccc;">import javax.microedition.media.Manager;<br />
import javax.microedition.media.Player;<br />
import java.io.IOException;</span></blockquote> and more... <a href="http://www.ziddu.com/download/18497830/BlackBerry-Java-Application-Development-Guide.pdf.html" target="_blank">click this link to get more explanation</a></div>Parwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.com0tag:blogger.com,1999:blog-6683401232273861207.post-21817883827649150622012-02-03T01:35:00.000-08:002012-02-03T01:49:37.383-08:00Multimedia Development Guide<b><span style="font-size: large;">BlackBerry Applications and multimedia</span></b><br />
<br />
<div style="text-align: justify;">You can create a BlackBerry® Application that plays media in the BlackBerry® Browser, or plays media in the media application on the BlackBerry smartphone. You can also create a BlackBerry Application that is a media application. You can create a BlackBerry Application that is a media application and plays binary SVG content. You can create an application that records audio or sends audio to a Bluetooth® enabled headset.</div><div style="text-align: justify;">For more information about media types that the BlackBerry smartphone supports, visit www.blackberry.com/btsc/support to read knowledge base article KB05482.<br />
<br />
</div><b><span style="font-size: large;">Using audio and video in a BlackBerry Application</span></b><br />
<b><br />
</b><br />
<b>Accessing stored media</b><br />
<b><br />
</b><br />
<div style="text-align: justify;">You can create a BlackBerry® Application that uses the Connector class and FileConnection interface to access media stored on the BlackBerry smartphone or a microSD card.<br />
<b>Access media on a BlackBerry smartphone</b><br />
<blockquote class="tr_bq">Invoke Connector.open(). Pass the following parameters: the file protocol and the location of the media file on the BlackBerry® smartphone.</blockquote> FileConnection fconn = (FileConnection)Connector.open("file:///store/home/user/audio/newfile.mp3");<br />
<br />
<b>Access media on a microSD card</b><br />
<blockquote class="tr_bq">Invoke Connector.open(). Pass the following parameters: the file protocol and the location of the media file on the microSD card.</blockquote> FileConnection fconn = (FileConnection)Connector.open("file:///SDCard/music/newfile.mp3");<br />
<br />
<b>Playing media in the BlackBerry Browser</b><br />
<b><br />
</b><br />
A BlackBerry® Application can use the methods of the Browser class and BrowserSession class to play media in the BlackBerry® Browser.<br />
<b><br />
</b><br />
<b>Play audio in the BlackBerry Browser</b><br />
<blockquote class="tr_bq">Invoke Browser.getDefaultSession().<br />
BrowserSession soundclip = Browser.getDefaultSession();<br />
Invoke BrowserSession.displaypage().<br />
soundclip.displayPage("file:///SDCard/BlackBerry/music/yourFile.mp3");</blockquote> <b>Play a video in the BlackBerry Browser</b><br />
<blockquote class="tr_bq">Invoke Browser.getDefaultSession().<br />
BrowserSession soundclip = Browser.getDefaultSession();<br />
Invoke BrowserSession.displaypage().<br />
soundclip.displayPage("file:///SDCard/BlackBerry/Video/soccergame.avi");</blockquote> <b>Playing media in the media application</b><br />
<b><br />
</b><br />
On the BlackBerry® smartphones that include the media application, a BlackBerry Application can use the javax.microedition.content and net.rim.device.api.content packages to start the media application with or without content.<br />
<br />
<b>Start the media application with or without content</b><br />
<ol><li>Import the javax.microedition.content package into your application code. <i>Import javax.microedition.content;</i></li>
<li>Invoke Registry.getRegistry(). Pass the following parameter: the classname parameter which is the name of the class in the application that extends <i>javax.microedition.midlet.MIDlet</i>, <i>net.rim.device.api.system</i>.Application, or <i>net.rim.device.api.ui</i>.UiApplication. Store a reference to the returned object in a Registry object. Registry reg = Registry.getRegistry(String classname);</li>
</ol>and more... <a href="http://www.ziddu.com/download/18497754/Multimedia_guide.pdf.html" target="_blank">click this link to get more explanation</a></div>Parwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.com1tag:blogger.com,1999:blog-6683401232273861207.post-40961598239294704082012-02-02T17:12:00.000-08:002012-02-03T01:32:35.900-08:00Unlock the secrets of advanced BlackBerry development<b><span style="font-size: x-large;">Advanced APIs</span></b><br />
<span style="text-align: justify;"><br />
</span><br />
<span style="text-align: justify;">The best BlackBerry apps take advantage of the rich set of advanced APIs available on</span><br />
<br />
<div style="text-align: justify;">this platform. The chapters in Part 1 describe some of the most exciting and compelling features available to you. Chapter 1 provides a crash course in building a variety of RIM applications that can access the local filesystem and the Internet. From there, learn how to use the device to shoot photos, record sound and video, and use the captured data in your app. Next, see the wide variety of options available for playing video, animations, and audio content. Connect the BlackBerry to the rest of the mobile world with wireless messaging and email technologies. Finally, incorporate today’s techniques for safeguarding data into your own applications.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><b><span style="font-size: x-large;">Getting Started</span></b></div><br />
<div style="text-align: justify;">Welcome to the wonderful world of BlackBerry app development! Chapter 1 is intended to get you up to speed as quickly as possible, so you can get right into the good stuff, and it assumes no previous knowledge other than a basic grasp of Java. This chapter will walk you through downloading software, setting up your environment, and then give you a quick tour through the basics of BlackBerry app development. You may linger, skim, or skip ahead as your patience demands.</div><br />
<b><span style="font-size: large;">Initial Setup</span></b><br />
<br />
<div style="text-align: justify;">As with any new language or platform, you will need to install some new software and set up your computer appropriately. There are many different ways to run a successful BlackBerry project. RIM supports only Windows development, but it has done a good job of releasing tools that enable development on a variety of configurations. This section will focus on what I have found to be the simplest and most effective setup for independent development, with occasional notes for alternative choices you might consider.</div><br />
<b><span style="font-size: large;">Getting Java</span></b><br />
<br />
<div style="text-align: justify;">You will be developing in Java for the BlackBerry, but before we get that far, we need to make sure Java on your desktop is running properly. RIM uses Java for their toolchain—the set of programs that will convert our application source files into a format that can run on the mobile device. Additionally, our Eclipse IDE requires a Java runtime environment.</div><br />
<div style="text-align: justify;">To see if Java is installed, open a command prompt. You can do this by clicking Start ➞Run, typing cmd, and pressing enter. A black-and-white command prompt window will appear. Type java -version. You should see something like the following:</div><br />
java version "1.6.0_14"<br />
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)<br />
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)<br />
<br />
The specific version number isn’t important, just getting a response. If Java is not installed or is not configured correctly, you will see an error like the following:<br />
<br />
'java' is not recognized as an internal or external command,<br />
operable program or batch file.<br />
<br />
<div style="text-align: justify;">To install Java, go to http://java.sun.com and look for the Java SE download. You only need to install the Java Runtime Environment (JRE). However, if you plan on doing other Java development besides BlackBerry, you can download the full Java Development Kit (JDK), which also includes the JRE.<br />
<blockquote class="tr_bq"><span style="background-color: #cccccc;"><b>Tip</b>: When installing any development software, I suggest you pick an install path that has no spaces in it. For example, instead of installing to c:\Program Files\Java, install to c:\dev\java. This will save you time in the future, as some Java programs and other useful utilities have a hard time working with files that have spaces in their name. Follow this rule for all the other downloads in this chapter, as well.</span></blockquote>Once you have downloaded and installed the JRE, try opening another command prompt and typing java -version again. If it still doesn’t recognize the command, you probably need to add Java to your PATH environment variable. In Windows XP, you can access this by right-clicking on My Computer, selecting Properties, clicking the Advanced tab, and then clicking Environment Variables. Make sure the path to your installed java.exe directory is included in the PATH. This will probably be something like c:\dev\java\jre1.6.0_14\bin.<br />
<br />
<b><span style="font-size: large;">Goldilocks and the Three IDEs</span></b><br />
<br />
Once upon a time, a developer was evaluating which IDE to use when writing BlackBerry<br />
apps. First she tried the RIM JDE. “Oh my!” she exclaimed. “This IDE is much too ugly!”<br />
Then she tried Netbeans. “This IDE doesn’t understand BlackBerry,” she complained.<br />
Finally, she installed Eclipse with the BlackBerry Plug-in. “Ahhh,” she smiled. “This IDE<br />
is just right!”<br />
<br />
The reality is that you can develop in any IDE that you want. The question is how much time and effort you will invest in getting everything to work right. I’ve found that Eclipse is the best platform for doing serious development, and it has only gotten better and easier since RIM released their official Plug-in. I will be using Eclipse for my examples in the rest of this book, and I recommend installing it unless you are already doing BlackBerry development in another environment.<br />
<br />
To get started, go to http://eclipse.org. I suggest you download a recent release of the Eclipse IDE for Java EE Developers. Depending on what other kinds of development you do, you may choose to use another package. This is fine, but Eclipse EE contains the most options and will give you the greatest flexibility.<br />
<br />
<blockquote class="tr_bq"><span style="background-color: #cccccc;"><b>Caution</b>: As of this writing, there are compatibility issues with Eclipse 3.5 (Galileo) and the<br />
BlackBerry JDE Plug-in for Eclipse. If you experience problems, use the older 3.4 (Ganymede)<br />
version of Eclipse. This is currently located in the Downloads page of the Eclipse web site,<br />
where you can select ‘‘Older Versions.’’ You can safely install multiple versions of Eclipse into<br />
separate directories on your computer.</span></blockquote>Eclipse doesn’t have a standard Windows installer. Instead, you simply unzip it to a folder on your computer. You could put it somewhere like c:\dev\eclipse. To make it easier to launch, you can right-click and drag the eclipse.exe icon to your desktop or task bar in order to create a shortcut.<br />
<br />
When you first launch Eclipse, it will ask you to choose a workspace. You can create one wherever you like. Do not check the option for “Use this as the default and do not ask me again.” One quirk of BlackBerry development is that each BlackBerry app you develop will require its own separate workspace, so you will be switching workspaces as you go through this book.<br />
<b><span style="font-size: large;"><br />
</span></b><br />
<b><span style="font-size: large;">Plugged In</span></b><br />
<br />
I have been a fan of Eclipse for many years now, in large part because of its very flexible and powerful Plug-in system. Plug-ins allow developers to tune their workspace for their specific tasks, without needing the bother of relearning a new tool for each new task.<br />
<br />
There are currently two ways to install the Plug-in. The first is to go to BlackBerry’s developer web page (currently located at http://na.blackberry.com/eng/developers/) and download the Plug-in as an EXE file. This is the simplest approach, as you can simply download the large file, run it, and then restart Eclipse.<br />
<br />
The other way to install the Plug-in is directly through Eclipse. I recommend taking this approach, as it allows you more control over what you install and provides a better way to get updates.<br />
<br />
In Eclipse, click the Help menu, then Software Updates. Click the Available Software tab, then click Add site. For the location, enter http://www.blackberry.com/go/eclipseUpdate. The BlackBerry Update Site will display. Several options are available. At a minimum, you will need to select the BlackBerry JDE Plug-in for Eclipse and at least one BlackBerry Component Pack.<br />
<blockquote class="tr_bq"><span style="background-color: #cccccc;"><b>Note</b>: You may be asked to enter a user name and password. You can register for a free<br />
developer account on the BlackBerry web site if you have not already done so. This prompt<br />
may appear multiple times, so continue entering the account name and password until it goes<br />
away. The servers hosting the Plug-in are sometimes temperamental and will fail with<br />
unhelpful messages; other times, the installation may appear to hang when it is actually<br />
progressing. If you cannot install through Software Updates, you can try again later, or install<br />
the EXE file directly as described above.</span></blockquote>If you have a particular BlackBerry device in mind, pick the Component Pack that matches the software version of that device. All these files are very large, so you should probably only start with a few even if you know you will eventually want more.<br />
<blockquote class="tr_bq"><span style="background-color: #cccccc;"><b>Tip</b>: You can find the software version on your BlackBerry by selecting Options, and then About. It should be a value like ‘‘4.5.0.81’’. When selecting a component pack, only the first two numbers are important. The rest will be used to select an appropriate simulator.</span></blockquote> You should restart Eclipse once the install is complete. After it restarts, you will see a new BlackBerry menu option at the top. You will also have access to two new debug configurations: BlackBerry Device and BlackBerry Simulator. Figure 1-1 shows what your Eclipse environment should look like once you have installed the Plug-in and started a new project.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSvm0UhrIFKDwkGKDH75uX9wBKNXS9A7mjIHl2MjWCWP12-K16EJ2TOJVf-cTnsuiT-Uc9_kcQpv-knHH5o-Gr2fgZdD7XkThimL0a6gw3zyBCc0DHl6h5EhXOb6RwM1Xgv73nzebb-U8/s1600/new.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="307" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSvm0UhrIFKDwkGKDH75uX9wBKNXS9A7mjIHl2MjWCWP12-K16EJ2TOJVf-cTnsuiT-Uc9_kcQpv-knHH5o-Gr2fgZdD7XkThimL0a6gw3zyBCc0DHl6h5EhXOb6RwM1Xgv73nzebb-U8/s400/new.png" width="400" /></a></div><b><span style="font-size: large;"><br />
</span></b><br />
<b><span style="font-size: large;">BlackBerry Programs</span></b><br />
<br />
If you are developing for a personal BlackBerry device, you probably already have the BlackBerry Desktop Manager and the BlackBerry Device Manager installed. If not, installing them is very easy. Go to http://www.blackberry.com and look for the “Desktop Software” download. You may need to select your provider and download the appropriate version for them. You will need to fill out a short form with your name and contact information. Run the downloaded setup file. You may be prompted to install additional software, such as the .NET Framework runtime. Once it’s complete, reboot your computer if prompted. The next time you connect your BlackBerry device to the computer, Windows should automatically install the drivers to access it.<br />
You can launch the BlackBerry Desktop Manager by going to your Start menu and looking under BlackBerry. Depending on your installation choices, the manager may automatically start when you log in to Windows. Figure 1-2 shows the BlackBerry Desktop Manager running.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv0NeFGUR5XvpkpIPMkA40SQA4Hg-f0E6xLYzpESCtpeGHWd43d6T-Js9EKwaaR6pXx5AV8yqRrXTb7Pm6efstte7k0BohfWLtq2-AJdLE_v2VD1gyUhRXCvJCp0apDYPpezlgDKeRULQ/s1600/bbdesktop.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="252" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv0NeFGUR5XvpkpIPMkA40SQA4Hg-f0E6xLYzpESCtpeGHWd43d6T-Js9EKwaaR6pXx5AV8yqRrXTb7Pm6efstte7k0BohfWLtq2-AJdLE_v2VD1gyUhRXCvJCp0apDYPpezlgDKeRULQ/s400/bbdesktop.png" width="400" /></a></div><b><span style="font-size: large;">Simulator Files</span></b><br />
<br />
Downloading the proper simulator files for the devices you plan to run on is essential, because different types of devices will have different screen sizes and input modes. Even if you have two devices with the same model number, they will behave differently depending on what software version they are running. Simulators are not just important for testing on the computer, though. They also contain essential information for debugging on the actual device.<br />
<br />
If you have the physical device you will be using, find the device software version by visiting Options, then About. You will be looking for a version that matches all parts of the version number. For example, if your device has version 4.5.0.81, only use 4.5.0.81, not another version that starts with 4.5.0. You can download simulator packs from the BlackBerry web site. The exact location will change, so your best bet is to visit the<br />
Developers page and look around for the BlackBerry Smartphone Simulators. You will see many, many choices. Pick the one that matches your exact version number and device model and, if applicable, carrier. You’ll need to click through another web form—get used to it, as there is no way to save your information. Download the simulator file, then run it to install. You can install to any directory you like.<br />
<br />
To switch to using a new simulator in Eclipse, follow these steps, and restart Eclipse if you are ever prompted to do so.<br />
<br />
<ol><li>Click the Window menu, then Preferences.</li>
<li>Expand the BlackBerry JDE menu and select Installed Components.</li>
<li>From the drop-down list, select the component pack that corresponds to your device version. For example, pick 4.5 for a device with version 4.5.0.81. If you don’t see your component pack listed, install it following the instructions in the section titled “Plugged In” earlier in this chapter.</li>
<li>Click the MDS Simulator option and navigate to the MDS directory that matches the component pack from Step 3.</li>
<li>Click OK. If you already have a project in Eclipse, you will be prompted to rebuild it.</li>
<li>Click Run, then Debug Configurations.</li>
<li>Create a new BlackBerry Simulator configuration.</li>
<li>Click the Simulator tab.</li>
<li>From the Profile drop-down, select the item that corresponds to the simulator you installed.</li>
</ol><div><div>You will now be able to use your device’s proper simulator, and you will have access to high-quality on-device debugging.<br />
<br />
</div></div><div><b><span style="font-size: large;">The Keys to Development</span></b><br />
<br />
So far, you have installed everything you need to get started writing BlackBerry software. There’s a catch, though: RIM has marked some of their APIs as restricted, and if your program uses any of these APIs, it will not run on the device unless it has been code signed.<br />
<br />
Code signing is covered in more detail in Chapter 9. For now, just be aware that this is often a necessary step in development. It can take from a few days to a few weeks to receive code signing keys, so start this early.<br />
<br />
You apply for the keys from the BlackBerry developer web site. Once again, you will need to fill out a form with information. As part of the form, you will be asked for an email address. Be aware that RIM will send multiple emails to this address every time you sign an application. Also, keep in mind that you must sign an application every time you make a change and load it on the device. It isn’t unusual for a large RIM app to generate 50 or more emails on a single signing. Therefore, I strongly urge you to enter an unmonitored email address here, or one where you can automatically delete emails from the signing server. If you use your personal email address instead, it will make your life miserable.<br />
<br />
The form also includes a question about Certicom cryptography keys. Certicom cryptography is covered in more detail Chapter 5; for now, you can just say “No” here. You should also pick a unique 10-digit PIN. There is a nominal charge for receiving code signing keys, currently $20. You will need one set of keys for each computer you will use for development. The RIM servers sometimes have problems; if you aren’t able to<br />
complete your order online, you can choose to fax it in instead.<br />
<br />
Eventually, you should receive an email from RIM with three key files and instruction on installation. Follow the email instructions. If you run into problems during your installation, follow the links in the email for more support. Once you have installed and registered the keys, you will be all set. You have a limited number of signatures, but the limit is absurdly high, so you don’t need to worry about ever running out.<br />
<br />
You will initially install the signing keys for a particular version of BlackBerry device software, such as 4.5 or 6.1. At first, you will only be able to sign applications built for that particular device type. There are two fixes for this, though: first, you can safely use an old version of the RIM signing tool on newer versions of device software. In other words, you can use the 4.5 signing tool on builds for 6.1, but not vice versa. Second, you can copy the files SignatureTool.jar, sigtool.db, sigtool.set, and sigtool.csk from one version of the desktop software to another. This also works to sign applications using both the BlackBerry Eclipse Plug-in and another environment on the same computer.<br />
<br />
<blockquote class="tr_bq"><div style="text-align: left;"><span style="background-color: #cccccc;"><b>Tip</b>: If you installed the BlackBerry Plug-in, your SignatureTool should be located in a directory like C:\dev\eclipse\plugins\net.rim.eide.componentpack4.5.0_4.5.0.16\components\bin.</span></div></blockquote>That’s it for setup! You now have all the tools you will need to write, debug, and install your own BlackBerry apps.<br />
<br />
and more ... <a href="http://www.ziddu.com/download/18497652/AdvancedBlackBerryDevelopmentDec2009.pdf.html" target="_blank">click this download link to get full explanation</a></div></div>Parwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.com0tag:blogger.com,1999:blog-6683401232273861207.post-8605118980755949982012-02-02T17:05:00.000-08:002012-02-02T17:05:14.511-08:00mukadimahSelamat datang di dunia indah pengembangan aplikasi BlackBerry! Bab 1 ini dimaksudkan<br />
untuk membuat Anda bangun untuk mempercepat secepat mungkin, sehingga Anda bisa mendapatkan tepat ke hal yang baik,<br />
dan tidak menganggap pengetahuan sebelumnya selain pemahaman dasar Java. bab ini<br />
akan memandu Anda melalui download software, menyiapkan lingkungan Anda, dan kemudian memberikan<br />
Anda tur singkat melalui dasar-dasar pengembangan aplikasi BlackBerry. Anda bisa berlama-lama,<br />
skim, atau langsung beralih sebagai tuntutan kesabaran Anda.<br />
<br />
Seperti halnya bahasa baru atau platform, Anda perlu menginstal beberapa perangkat lunak baru dan<br />
mengatur komputer Anda dengan tepat. Ada banyak cara untuk menjalankan sukses<br />
BlackBerry proyek. RIM hanya mendukung pengembangan Windows, tetapi telah melakukan yang baik<br />
tugas melepaskan alat-alat yang memungkinkan pengembangan pada berbagai konfigurasi. ini<br />
bagian akan fokus pada apa yang saya temukan untuk menjadi setup sederhana dan paling efektif untuk<br />
independen pembangunan, dengan catatan sesekali untuk alternatif pilihan Anda mungkin<br />
dipertimbangkan.<br />
<br />
Anda akan mengembangkan di Java untuk BlackBerry, tapi sebelum kita sampai sejauh itu, kita perlu<br />
membuat Java yakin pada desktop Anda berjalan dengan benar. RIM menggunakan Java untuk mereka-toolchain<br />
serangkaian program yang akan mengkonversi file sumber aplikasi Anda ke dalam format yang dapat<br />
berjalan pada perangkat mobile. Selain itu, kami Eclipse IDE membutuhkan runtime Java<br />
lingkungan.<br />
Untuk melihat apakah Java terpasang, membuka prompt perintah. Anda dapat melakukan ini dengan mengklik Start ?<br />
Jalankan, ketik cmd, dan menekan enter. Sebuah jendela hitam-putih command prompt akan<br />
muncul. Ketik java-version. Anda akan melihat sesuatu seperti berikut:<br />
<br />
<br />
java version "1.6.0_14"<br />
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)<br />
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)Parwantohttp://www.blogger.com/profile/00497619017490543195noreply@blogger.com0