Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
lakshman9687
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

How to display audio and video files with Thumbnails

Hi All,

 

How to display audio and video files present in the device with Thumbnails like default app "Media" in the device.

is it possible to display, if yes please give me any Lib or sample code or any links.

for more details please see the attachments

 

Thanks in advance.

 

Regards,

Lakshman K

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Please use plain text.
Developer
lakshman9687
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How to display audio and video files with Thumbnails

Hi,

 

Can anyone plz help me, any link or any sample code...

 

Thanks in advance.

 

Regards,

Lakshman K

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Please use plain text.
Developer
lakshman9687
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How to display audio and video files with Thumbnails

Hi All,

 

anyone plz reply me,or tell me is it possible or not?

 

Thanks in advance.

 

Regards,

Lakshman K

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to display audio and video files with Thumbnails

Just wanted to let you know your question had been seen.  However I have not responded because I have no idea how to do this.  Sorry.  Good luck. 

Please use plain text.
Developer
lakshman9687
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How to display audio and video files with Thumbnails

Hi Peter, thanks for your reply.

 

Ok i will wait for reply , who know this problem. If any development adviser reply this thread wether it is possible or not then i can show this to my people.

 

Thanks in advance.

 

Regards,

Lakshman k

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Please use plain text.
Developer
lakshman9687
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How to display audio and video files with Thumbnails

Hi Peter,

 

Displaying thumbnails for audio i am trying this below thread

 

http://supportforums.blackberry.com/t5/Java-Development/Thumbnails-work-around/td-p/343870

 

but i am getting byte array with the lent 4 and all are zeros can you help me where i am going wrong. my code is

 

FileConnection fc = null;
			InputStream in = null;
			try 
			{
				fc = (FileConnection) Connector.open(Tools.APP_DIR+"BBThumbs.dat", Connector.READ);
				if (!fc.exists()) 
				{
					Dialog.alert("File not found.");
				}
				in = fc.openInputStream();
				byte[] bbthumb = IOUtilities.streamToBytes(in);
				thumb = readThumbs(bbthumb,"Keka.mp3");
//				b = getThumbNail(first, thumbsMap, fileName, in);
			} catch (Exception e) 
			{
				Dialog.alert("Exception.");
			} 
			finally 
			{
				if (fc != null) {
					try {
						fc.close();
					} catch (Exception e) {
					}
				}
				if (in != null) {
					try {
						in.close();
					} catch (Exception e) {
					}
				}
			}
		}
		if(thumb != null && thumb.length > 0)
		{
        	img =  EncodedImage.createEncodedImage(thumb, 0, thumb.length).getBitmap();
        	this.add(new BitmapField(img));
		}

and readThumbs method is:

public static byte[] readThumbs(byte[] search, String szSearch) 
	{

	//convert the search string to bytes for easier comparison
		try 
		{
			System.out.println("Thumbnail data is:"+ new String(search,"UTF-8"));
			System.out.println("Thumbnail data is:"+ new String(search));
			System.out.println("Thumbnail bytes data is:"+ search);
		} 
		catch (UnsupportedEncodingException e)
		{
			e.printStackTrace();
		}
		byte[] searchtmp = szSearch.getBytes();
		System.out.println("File data is:"+ new String(searchtmp));
		System.out.println("File bytes data is:"+ searchtmp);
		for (int x = 0; x < search.length; x++) 
		{
			boolean found = false;
			int lastbyte = 0;

	  //For the length of searchtmp trying to find a match in the byte file

	//we could also have converted search to String [new String(search)]

	//and have done an index of however I prefer direct byte access as

	//lookups tend to be faster

			for (int y = 0; y < searchtmp.length; y++) 
			{
				if (search[x+y] == searchtmp[y]) 
				{
					lastbyte = x+y+1;
					found = true;
				} 
				else 
				{
					found = false;
					break;
				}
			}

			if (found) 
			{

	  //we found our search string so next we want to see how long in

	//bytes the files is so we only read untill end of this PNG

	//without needing to search for the AE 42 50 82 Hex String,

	//also there might be a chance that AE 42 50 82 repeats itself

	//as such it is highly recommended to get the size

				byte[] tmpB = new byte[4];
				tmpB[0] = search[lastbyte+20];
				tmpB[1] = search[lastbyte+19];
				tmpB[2] = search[lastbyte+18];
				tmpB[3] = search[lastbyte+17];
				long readsize = 0;
				int t = 0;

	  //convert and retrieve the size

				for (int shiftBy=0; shiftBy<32; shiftBy+=8) {
					readsize |= (long)(tmpB[t++] & 0xff) <<shiftBy;
				}
				tmpB = null;
				tmpB = new byte[(int)readsize];
				t = 0;

	  //now we read from the start of the image untill the end of

	//the image

				for (int y = lastbyte+21; y < (int)readsize+lastbyte+21; y++) 
				{
					tmpB[t++] = search[y];
				}

	  //and like that we have our bitmap

	//now all that is left to do is to convert it using

	//Bitmap.createBitmapFromBytes(tmpB, x, y, z);

				return tmpB;

			}
		}
		return null;
	}

 here "keka.mp3" file is available in my sd card folder, i am getting output is:

b[] = [ 0,0,0,0]

so i am getting illegal argument exception bcz of "EncodedImage.createEncodedImage" with empty byte array.

 

Thanks in advance,

 

Regards,

Lakshman k

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Please use plain text.