PERSONAL MEDIA CLOUD APPLICATION FOR ANDROID

pullfarmInternet and Web Development

Nov 3, 2013 (3 years and 7 months ago)

166 views

PERSONAL
MEDIA CLOUD APP
LICATION

FOR ANDROID


Prajakta Sarurkar

B.E
.
,
Nagpur University
,

2000




PROJECT




Submitted in partial satisfaction of

the

requirements for the degree of




MASTER OF
SCIENCE


in



COMPUTER SCIENCE

at

CALIFORNIA STATE UNIVERSITY, SACRAMENTO


SPRING

2012






ii




















© 2012

Prajakta Sarurkar

ALL RIGHTS RESERVED



iii

PERSONAL MEDIA CLOUD APPLICATION FOR ANDROID



A Project



by



Prajakta Sarurkar







Approved by:


__________________________________, Committee Chair

Du Zhang, Ph.D.


__________________________________, Second Reader

Mary Jane Lee, Ph.D.



____________________________

Date







iv

Student:
Prajakta Sarurkar



I certify that this student has met the requirements for format contained in the University
format manual, and that this project is suitable for shelving in the Library and credit is to
be awarded for the project.








__________________________, Graduate Coordinator


___________________

Nikrouz Faroughi, Ph.D.






Date










Department of Computer Science





v

Abstract

of

PERSONAL MEDIA CLOUD APPLICATION FOR ANDROID

by

Prajakta Sarurkar


Recent advances in communication technologies have enabled an
exponential growth in
connected devices like Android smart phones and tablets. These devices are mainly used
for content consumption.

However, limited resources available on these devices, as well
as always connected internet accessibility
makes

these devi
ces ideal platforms for cloud
computing.

This project is an attempt at creating
personal
media cloud
player app
for Android smart
phone devices. The project uses off the shelf
hardware

components
for
private
cloud
implementation
and Java programming over A
ndroid to provide full featured
media
cloud
platform. This
private
media cloud
enables

users to
:



Store media files (images/audio/video etc) in the cloud



Access the media files from
their
Android device

Additionally, the project aims at providing following
features:



File browsing



Audio streaming (MP3)



Video streaming (MP4)



vi



Images (JPEG/PNG)



e
-
radio/ Photo Slide Show

The project aims at developing an application that can be used by any Android (version
2.2 and higher) smartphone to implement above mentioned
media functionality.





, Committee Chair

Du Zhang, Ph.D.

______________________

Date




vii

DEDICATION










To my family













viii

ACKNOWLEDG
E
MENTS


I would like to tha
nk my project advisor Dr. Du Zhang for
taking time and giving me
guidance through the project.

I would also like to thank all the professors who taught me during my masters’ course
work.

I would like to thank my family for all the support.


















ix

TABLE OF CONTENTS

Dedication

................................
................................
................................
.........................

vii

Acknowledgements

................................
................................
................................
..........

viii

Table Of Contents

................................
................................
................................
..............

ix

L
ist

O
f

F
igures

................................
................................
................................
..................

xii

L
ist Of

T
abl
es

................................
................................
................................
..................

xiii

1
INTRODUCTION

................................
................................
................................
..........

1

1.1

Current state of practice for Media Cloud

................................
............................

1

1.2

Scope of the project

................................
................................
..............................

2

1.3

Benefits of Media Cloud App

................................
................................
..............

3

2

BACKGROUND

................................
................................
................................
............

5

2.1

Current exis
ting Cloud Media Storage

................................
................................
.

5

2.2

Cloud Fundamentals

................................
................................
.............................

8

2.3

Cloud APIs

................................
................................
................................
.........

12

2.4

Androi
d Apps

................................
................................
................................
.....

14

2.5

Android
application components

................................
................................
.......

17

2.5.1

Activities

................................
................................
................................
.........

17

2.5.2

Services

................................
................................
................................
.......

18

2.5.3

Content
providers

................................
................................
........................

18

2.5.4

Broadcast receivers

................................
................................
.....................

19

3

ARCHITECTURE AND TECHNOLOGY

................................
................................
..

21



x

3.1

Basic Architecture of Media Player app

................................
............................

21

3.2

Features

................................
................................
................................
...........

22

3.3

Application

................................
................................
................................
.....

23

4

IMPLEMENT
ATION DETAILS

................................
................................
.................

25

4.1

Media cloud

................................
................................
................................
........

25

4.2

Android APIs

................................
................................
................................
..

28

4.3

Android
client

................................
................................
................................
.....

30

4.3.1

Login Screen

................................
................................
...............................

30

4.3.2

Main Screen

................................
................................
................................

31

4.3.3

File View

................................
................................
................................
.....

32

4.3.4

Music player
................................
................................
................................

33

4.3.5

Image Viewer

................................
................................
..............................

34

4.3.6

Video player

................................
................................
................................

35

4.3.7

File Uploading

................................
................................
............................

36

5

PERFO
RMANCE EVALUATION

................................
................................
..............

37

6

CONCLUSION AND FUTURE WORK

................................
................................
.....

39

6.1

Future work

................................
................................
................................
........

39

6.1.1

Playlist Management

................................
................................
...................

39

6.1.2

File Sharing

................................
................................
................................
.

3
9

6.1.3

Folder sync up

................................
................................
.............................

40




xi

A
ppendix

Source Code

................................
................................
................................
.....

41

B
ibliography

................................
................................
................................
.....................

97






xii

LIST OF FIGURES



Page

Figure 1: Typical
cloud configuration

................................
................................
................

9

Figure 2: Cloud storage setup using Pogoplug

................................
................................
.

11

Figure 3: Architecture of Pogoplug device

................................
................................
.......

12

Figure 4: Architec
ture of Cloud Media player app

................................
...........................

22

Figure 5: Control flow in Cloud Media player app
................................
...........................

24

Figure 6: Login Screen
................................
................................
................................
......

31

Figure

7: Main Screen

................................
................................
................................
.......

32

Figure 8: File view

................................
................................
................................
............

33

Figure 9: (A)
-

Audio player screen, (B)


Radio player screen

................................
.......

34

Figure 10: (A)
-

Image
diaglog box, (B)


Loaded image

................................
................

35

Figure 11: File uploading

................................
................................
................................
..

36







xiii


LIST OF TABLES













Page


Table 1: Media formats supported by Media Cloud App

................................
...................

2

Table 2: Comparative study of various cloud implementations

................................
.........

6

Table 3: Pogoplug Specifications

................................
................................
.....................

11

Table 4: Pogoplug APIs

................................
................................
................................
....

27

Table 5: Android APIs

................................
................................
................................
......

29

Table 6: Media Cloud app performance evaluation

................................
..........................

38


1


Chapter 1

INTRODUCTION

Smartphones
along with Tablet computers
are turning out to be the “next big thing” in
crowded electronic gadget industry

[
1
]. Customizable features, powerful gesture based
user interface, and always ON connectivity are the key features that are resulting in
widespread popularity of smartphone devices. Smartphones are also responsible for
growing interest in cloud computing,
es
pecially

in the domain of media consumption

[
2,
3
]. Always ON internet connectivity allows users to easily access data from remote
servers in the cloud

[4]
. This enables users to easily store digital multi
-
media in the cloud
and access them from anywhere,
anytime.


1.1

Current state of practice for Media Cloud

Feature rich Android Smartphones
and Tablet computers
have enabled a wide range of
applications and new usage models
, including cloud based applications
. However, use of
cloud based media storage is
becom
ing popular only after faster connection speeds
offered by 3G and 4G communication networks
. Some applications such as Pandora and
You Tube do exist that allow cloud like media streaming but these applications can only
stream content available on respectiv
e web sites and not personal collection.

Recently companies such as Amazon and Apple have made media cloud service available

[5, 6]

but
these are targeted towards media purchased on the Amazon or iTunes
respectively. Apple’s iCloud does allow uploading pe
rsonal files but it is more expensive
2


than having personal cloud device. Currently,

there
are a few
application
s

available that
will allow users to access their personal cloud storage using their smartphone devices.


1.2

Scope of
the project

This project aims
at setting up
a
personal media cloud

[17]

using standard off the shelf
components. Additionally, the project aims at developing an Androi
d app that will enable
Android S
martphone
s and Tablet computers

to access the media stored on cloud and
allows media pl
ayback.

Media Type

Format

File Type

Details

Audio

AAC/HE
-
AACv1/HE
-
AACv2

.3gp/.mp4

Mono/Stereo,
Bit rates up to
160kHz

Audio

MP3

.mp3

Mono/Stereo,
bit rates 8
-
320k

Audio

MIDI

.mid

MIDI Type 0
and Type 1

Image

JPEG/GIF/PNG/BMP

.jpg/.gif//.png/.bmp


Video

H.263

.3gp/.mp4



Table
1
: Media formats supported by Media Cloud App


3



The media app will support following features:



File browsing



Image Viewer



Audio Playback



Video Playback

Media app will allow streaming media over
internet. Table 1 shows media formats that
will be supported by the app.


1.3

Benefits of Media Cloud App

Growing popularity of Android Smartphones

and Tablet computers

is helping
cloud
based data storage to grow popular as well.
Morevoer, in
today’s digital w
orld people are
increasingly finding ways to store the media in cloud. Cloud storage also allows people to
eas
ily share their personal media.
Media cloud app allows users to easily access media
stored in
their personal
cloud
device

using Android smartphone
s and tablets
. It will also
address shortcomings in currently available media cloud app such as video streaming, file
upload, photo slideshow, e
-
radio etc.

Rest of this report is divided in several chapters. Chapter 2 includes the background
information on

cloud storage as well as Android apps. Detailed information on setting up
cloud storage and Android application development is presented. Chapter 3 includes the
architecture and features of the Media Cloud App. Chapter 4 includes implementation
4


details of

different modules of the Media Cloud App. Chapter 5 includes the performance
evaluation of the Media Cloud App. Chapter 6 includes the conclusion and future work.




5


Chapter 2

BACKGROUND

Chapter 1 discussed the need for an Android app that supports cloud

based media storage.
This chapter provides background information including cloud fundamentals as well
Android app development.


2.1

Current existing Cloud Media Storage

Media centric cloud computing is rapidly evolving field and a number of advances are
happening in this area

[4]
.
Table 2 shows the comparative details about various clouds
available to users.
Most noteworthy are
Apple’s iCloud [4],
Amazon cloud media player
[5],
Zumodrive

[7]
, and Pogoplug [10]
.

iCloud is a well integrated cloud service wi
th Apple. This service is integrated with
various Apple devices such iPhone, iPod, iMac etc. This service allows user to store
media such as photos, music and documents, in addition to apps, calendar etc. However
iCloud does not support video streaming.







6


CRITERIA

I
CLOUD

AMAZON

ZUMO
DRIVE

POGOPLUG

Cloud
Type

Commercial
Cloud Service

Commercial
Cloud Service

SW Cloud
adapter

Cloud
App


Storage
Limit

Up to 100GB

Up to 1TB

Depends on
HD

Depends on HD

Cost/GB

$2/year (for
100GB)

$1/year (for
1TB)

~ $2/year plus
Hardware

cost
(for 500GB)

~10¢ fixed cost
(for 2TB)

Services

Apps, Music,
Photo, Docs

Music storage,
streaming

Music, picture
storage,
streaming

Store any type
of file, Audio

Advantages

Integrated
with Apps

Integrated with
Amazon

Integrates
with iTunes,
Picasa

Low cost,
standard based
interfaces

Limitations

No Video
Streaming

No Video
Streaming

No Video
Streaming

No Automatic
Sync

No Video
streaming


Table
2
: Comparative study
of various cloud implementations


7


Amazon, the largest online retailer recently announced online media storage service with
a cloud media player for Android devices. The newly launched service will help users in
storing application, songs and other digital
media, and will also enable Android users to
stream music stored on the Amazon servers with a Cloud Drive Player application. The
application supports most commonly used file types, including AAC and MP3, and
streams the media back at the full bit rate of
the original file. Cloud media player
supports some common controls like play, pause, skip and users can even build their own
playlists. However, this service will not support video streaming. Moreover, uploading
music from mobile device is not currently s
upported, although music files may be
uploaded from PC or Mac. This solution also does not support syncing media files from
device to the cloud.

ZumoDrive is a cloud media storage solution that supports devices running Android 1.6
and later versions. Users

install the ZumoDrive application on their PC computer which
enables them to access media files such as music and photos using the ZumoDrive app on
Android device. ZumoDrive supports sharing any type of media file, however this
solution does not support v
ideo streaming. This solution also does not support syncing
media files from device to the cloud.

Pogoplug cloud app is
used to connect with

Pogoplug cloud adapter. Pogoplug cloud
adapter
allows users to connect their own hard disk drives to cloud. Users c
an then access
these hard drives on their Android Smartphones and Tablet

computer
s using Pogoplug
8


cloud app. Pogoplug cloud app lacks certain features such as video streaming,
automatic
file sync, photo slide show, and e
-
Radio.


2.2

Cloud Fundamentals

Cloud is

the term used to describe
servers
connected to internet such that client
applications can interact with
the servers and
storage as long as
internet
connectivity can
be guaranteed

[8]
.

Perosnal media cloud refers to a small server in a home or small busin
ess network that
can be accessed over the Internet. Designed for sharing photos and videos, personal
clouds enable viewing and streaming from any Internet
-
connected personal computer and
from Android smartphones [17].

Typical cloud configuration is shown
in
Figure

1. As shown, a cloud system consists of a
server connected to the internet via high speed link. The server may also
be
connected to
a mass storage system
, such as a hard drive
. A client such as a smartphone or any device
capable of connecting to
internet can then communicate with the server

[9]
. In this
configuration, the server may provide either comput
ing
services or storage services or a
combination of both. Present project requires the server to provide storage and media
streaming services.

So
metimes user can connect their own hard disk drives to the server
to form personal media cloud systems.


9




















Figure
1
: Typical cloud configuration


Cloud systems are characterized with 4 properties

[9
, 16
]
:

1.

Consistency
: A
bility of a computer
-
related hardware or software component
to consistently perform according to its specifications

Cloud
STORAGE
SERVER
CLIENT
10


2.

Availability: Ability of the system to perform work when it is expected to
perform work

3.

Partition Tolerance: Ability of the system to perform
in the event of arbitrary
message loss or failure of part
of the system

4.

Response Time:
Time taken to complete requested operation

With these criteria in mind, a search for suitable
hardware

devices was conducted. A
number of devices were studied, including,



Iomega iConnect Wireless Data Station



Verbatim
MediaShare Mini Home Network Storage



Seagate FreeAgent GoFlex Net Media Sharing Device



Western Digital My Book Live Personal Cloud Storage Device



Cirago Network USB Storage Link



Pogoplug

The device named pogoplug was selected, mainly due to the open source

software
components and ability to interface with third party software

[10]
.


Pogoplug is a multimedia sharing device from CloudEngines that acts as a server
connecting to any external hard drive using USB ports. Typical cloud storage setup using
pogoplug

is shown in
Figure

2 [
11
]. Once the hard drive connection over USB port is
setup, the content on hard driver can be accessed and shared over the internet. Pogoplug
works across multiple platforms and allows streaming videos, music and ph
otos without
any m
onthly fees [10
]. Pogoplug specificat
ions are indicated in Table 1 [12
].

11





Figure
2
: Cloud storage setup using Pogoplug



Parameter

Specification

Power Requirements

100
-
240V, 50
-
60Hz

Hard drive
connection

USB 2.0

File System
Formats


NTFS, FAT32, Mac OS Extended Journaled and non
-
Journaled (HFS+), EXT
-
2/EXT
-
3

Network Connection

Gigabit Ethernet

Operating Systems

MS Windows XP, Vista, Windows 7, Mac OSX 10.5 and
above (Intel and PowerPC) 32bit kernel only, Linux

Web Browsers

Safari, FireFox 3, IE 7, IE 8, Google Chrome

Web APIs

Javascript, Java, PHP, .NET, C++


Table
3
: Pogoplug Specifications

12



2.3

Cloud APIs

As mentioned in earlier section, primary reason we selected
P
ogoplug device to
implement cloud storage is because the device is based on open architecture. Internal
architecture of Pogoplug device is shown in
Figure

3. As shown, Pogoplug device is a
Linux

machine based on ARM compatible processor

[12]
.



ARM CPU
HDD
/
USB CONTROLLER
HARDWARE ABSTRACTION AND DRIVERS
LINUX OS
POGOPLUG API
NETWORK CONTROLLER
Gigabit Ethernet
USB ports for HDDs

Figure
3
:
Architecture of Pogoplug device


13


All Pogoplug API methods support HTTP (and HTTPS) protocol transport mechanisms.
The API has been designed to transparently support both REST style and SOAP style
HTTP
calling conventions. All responses to API call requests are either raw data
responses or structured responses depending on the API call in question. Structured
responses are provided in either SOAP, Simple XML, or JSON format depending on the
arguments use
d to invoke the API call

[13]
.

All
API method calls are supported through a base URL such as:

http://service.pogoplug.com/svc/api

Invoking methods are performed with URLs constructed by the following pattern:

http://service.pogoplug.com/svc/api[/format][/m
ethodName]

Where format is optional response format (e.g. soap, xml, json) and methodName is the
name of the method to be invoked. As an example, invoking the method getVersion
would be performed on any of the following URLs:

http://service.pogoplug.com/sv
c/api/getVersion

http://service.pogoplug.com/svc/api/xml/getVersion

http://service.pogoplug.com/svc/api/json/getVersion

http://service.pogoplug.com/svc/api/soap/getVersion

The argument calling convention is implied by the HTTP request type. An HTTP GET
req
uest to the URL will imply a REST style call with arguments passed on the query
string in standard browser form query string encoding. Thus, for example, invoking
method loginUser can be performed with a REST style call by performing an HTTP GET
on the fol
lowing URL:

14


http://service.pogoplug.com/svc/api/loginUser?email=test@pogoplug.com&p
assword=test

Similarly, an HTTP POST request to the URL will imply a SOAP style call with
arguments encoded inside a SOAP XML envelope passed as the request body of the
HTTP

request.

The response format is implied based on the calling convention or specified specifically
in the URL. The implied response for REST style requests is JSON, and the implied
response for SOAP style requests is SOAP.

Exceptions can be returned from

any API call rather than the structured response that was
expected. Exceptions will always be of the same form and encode some level of useful
information for converting to a user presentation error message.

Exceptions will be returned with HTTP 500 leve
l response codes in the HTTP header.


2.4

Andro
i
d Apps

Android applications are written in the Java programming language

[14]
. The Android
SDK tools compile the code

along with any data and resource files

into an Android
package, an archive file with an .apk s
uffix. All the code in a single .apk file is
considered to be one application and is the file that Android
-
powered devices use to
install the application.

Once installed on a device, each Android application lives in its own security sandbox:



The Android o
perating system is a multi
-
user Linux system in which each
application is a different user.

15




By default, the system assigns each application a unique Linux user ID (the ID is
used only by the system and is unknown to the application). The system sets
permis
sions for all the files in an application so that only the user ID assigned to
that application can access them.



Each process has its own virtual machine (VM), so an application's code runs in
isolation from other applications.



By default, every applicatio
n runs in its own Linux process. Android starts the
process when any of the application's components need to be executed, then shuts
down the process when it's no longer needed or when the system must recover
memory for other applications.

In this way, the

Android system implements the principle of least privilege. That is, each
application, by default, has access only to the components that it requires to do its work
and no more. This creates a very secure environment in which an application cannot
access
parts of the system for which it is not given permission.

However, there are ways for an application to share data with other applications and for
an application to access system services:

It's possible to arrange for two applications to share the same
Linux user ID, in which
case they are able to access each other's files. To conserve system resources, applications
with the same user ID can also arrange to run in the same Linux process and share the
same VM (the applications must also be signed with the

same certificate).

16


An application can request permission to access device data such as the user's contacts,
SMS messages, the mountable storage (SD card), camera, Bluetooth, and more. All
application permissions must be granted by the user at install time
.

A unique aspect of the Android system design is that any application can start another
application’s component

[15]
. For example, if you want the user to capture a photo with
the device camera, there's probably another application that does that and your

application can use it, instead of developing an activity to capture a photo yourself. You
don't need to incorporate or even link to the code from the camera application. Instead,
you can simply start the activity in the camera application that captures a

photo. When
complete, the photo is even returned to your application so you can use it. To the user, it
seems as if the camera is actually a part of your application.

When the system starts a component, it starts the process for that application (if it's
not
already running) and instantiates the classes needed for the component. For example, if
your application starts the activity in the camera application that captures a photo, that
activity runs in the process that belongs to the camera application, not
in your
application's process. Therefore, unlike applications on most other systems, Android
applications don't have a single entry point (there's no main() function, for example).

Because the system runs each application in a separate process with file pe
rmissions that
restrict access to other applications, your application cannot directly activate a component
from another application. The Android system, however, can. So, to activate a component
17


in another application, you must deliver a message to the sy
stem that specifies your intent
to start a particular component. The system then activates the component for you.


2.5

Android application components

Application components are the essential building blocks of an Android application

[15]
.
Each component is a d
ifferent point through which the system can enter your application.
Not all components are actual entry points for the user and some depend on each other,
but each one exists as its own entity and plays a specific role

each one is a unique
building block t
hat helps define your application's overall behavior.

There are four different types of application components. Each type serves a distinct
purpose and has a distinct lifecycle that defines how the component is created and
destroyed.


2.5.1

Activities

An activity represents a single screen with a user interface. For example, an email
application might have one activity that shows a list of new emails, another activity to
compose an email, and another activity for reading emails. Although the activities
work
together to form a cohesive user experience in the email application, each one is
independent of the others. As such, a different application can start any one of these
activities (if the email application allows it). For example, a camera application

can start
18


the activity in the email application that composes new mail, in order for the user to share
a picture.

An activity is implemented as a subclass of Activity and you can learn more about it in
the Activities developer guide.


2.5.2

Services

A service
is a component that runs in the background to perform long
-
running operations
or to perform work for remote processes. A service does not provide a user interface. For
example, a service might play music in the background while the user is in a different
a
pplication, or it might fetch data over the network without blocking user interaction with
an activity. Another component, such as an activity, can start the service and let it run or
bind to it in order to interact with it.

A service is implemented as a s
ubclass of
Service
.


2.5.3

Content providers

A content provider manages a shared set of application data. You can store the data in the
file system, an SQLite database, on the web, or any other persistent storage location your
application can access. Through th
e content provider, other applications can query or
even modify the data (if the content provider allows it). For example, the Android system
provides a content provider that manages the user's contact information. As such, any
19


application with the proper
permissions can query part of the content provider (such as
ContactsContract.Data) to read and write information about a particular person.

Content providers are also useful for reading and writing data that is private to your
application and not shared. F
or example, the Note Pad sample application uses a content
provider to save notes.

A content provider is implemented as a subclass of ContentProvider and must implement
a standard set of APIs that enable other applications to perform transactions. For more

information, see the Content Providers developer guide.


2.5.4

Broadcast receivers

A broadcast receiver is a component that responds to system
-
wide broadcast
announcements. Many broadcasts originate from the system

for example, a broadcast
announcing that the s
creen has turned off, the battery is low, or a picture was captured.
Applications can also initiate broadcasts

for example, to let other applications know
that some data has been downloaded to the device and is available for them to use.
Although broadcast

receivers don't display a user interface, they may create a status bar
notification to alert the user when a broadcast event occurs. More commonly, though, a
broadcast receiver is just a "gateway" to other components and is intended to do a very
minimal a
mount of work. For instance, it might initiate a service to perform some work
based on the event.

20


A broadcast receiver is implemented as a subclass of BroadcastReceiver and each
broadcast is delivered as an Intent object. For more information, see the
Broa
dcastReceiver class.






21


Chapter 3

ARCHITECTURE AND TECHNOLOGY

Chapter 1 and Chapter 2 provided background information about Media player app. This
chapter provides detailed information about architecture and design of the Media player
app.


3.1

Basic A
rchit
ecture

of Media Player app

As mentioned in
Chapter 2, Media player app is designed for Android phones. Like any
cloud computing application, Media player app uses client
-
server model.
Figure
4

shows
the basic architecture of the Media player app along with cloud storage. As shown in the
figure, cloud based Media player consists of:



Application
:

User interacts with cloud based Media

player using the application.
Application is responsible for accepting user inputs and reacting to user’s input.
Application interacts with Androind OS via the Android APIs.



Android APIs:

Media player app interacts with Android phone OS using
Android APIs
. Please refer to section
4.2

for more information about Android
APIs.



Android OS:

The application will use Android APIs to interact with the OS. OS
will then control the
hardware

to communicate with the cloud.



Cloud:

Cloud is the medium that will forward the request from client to the server
that is connected to the cloud.

22




Linux OS:

On

the server side, incoming messages will be forwarded to the OS in
the Pogoplug controller box.



The OS will forward the requests to the HTTP server.



HTTP Server:

HTTP server is crucial to making overall data transfer work.
HTTP server will resolve the inco
ming message and forward them the storage that
is connected to Pogoplug box.

APPLICATION
ANDROID APIs
ANDROID OS
LINUX OS
HTTP SERVER
POGOPLUG APIs
Cloud
CLIENT
SERVER

Figure
4
: Architecture of Cloud Media player app


3.2

Features

Section 1.2 discussed that features supported by Cloud Media app a
re:

23




File browsing



Image Viewer



Audio Playback



Video Playback



Photo Slide Show



E
-
Radio



File upload

Also, as discussed in section 3.1, Cloud Media app needs to communicate with Pogoplug
to access the media files.


3.3

Application

Section
2.4

provided information about Android application. As explained in section
2.4
,
an android application consists of activities, services, content providers, and broadcast
receivers. A typical app may or may not use all these components. Cloud Media player
app mostly consists of activities. Activities are classes that must extend the
Activity

base class and must implement
onCreate

method.
Figure
5

shows various activities
required for Cloud Media player app.
Figure
5

also shows how various activities interact
with each other in the application.

24


AudioPlayerActivity
FileScreenActivity
ImageViewerActivity
LoginScreenActivity
RadioScreenActivity
SlideShowActivity
UserScreenActivity
VideoPlayerActivity
FileUploaderActivity

Figure
5
:
Control flow
in Cloud
Media player app


As shown in the figure, LoginScreenActivity is the class that is instantiated when the
application starts. When user login is successful, LoginScreenActivity will start
UserScreenActivity. UserScreenActivity will display the main screen. Next, based on
use
r input UserScreenActivity will start any one of FileScreenActivity,
FileUpload
er
Activity,
VideoPlayerActivity, AudioPlayerActivity, ImageViewerActivity,
RadioPlayerActivity, and SlideShowActivity. Each of these activities will present their
own screens to

the user and take appropriate actions. More details about each of the
activity classes are provided in section
4.3
.

25



Chapter 4

IMPLEMENTATION DETA
ILS


This chapter discusses the implementation details such as Android API used, APIs used
to interact with the cloud, and structure in which the application is developed.


4.1

Media cloud

The
Pogoplug

device is the cloud that stores all the media files and t
he application uses
Pogoplug

APIs to interact with the cloud.
Pogoplug supports APIs using standard
HTTP
GET/PUT

commands.
The main features provided by the cloud
are

the storage of the
media files and easy and structured access to this stored data.

The
structured
Pogoplug

APIs provide object oriented API access to different object
classes within the system

[
1
3
]. Major classes in the APIs are

1.

User

This
object represents all the details of the user. These details include the user id,
screen name, primary

email address, list of registered email addresses for the user
and a field containing the details if the email id is validated or not.

2.

Service

This object contains device id that owns the service, service id, service class, type
of access to this service,

user’s name for the service, version string of the service,
api url to use when using the service, on line status.

26


3.

Device

Device object consists of details such as device id, device name, version string,
flags about the device, user id of the owner, list
of services representing services
on this device and user object representing the owner of this device.

4.

File

File object represents the file stored on the cloud. It consists of file id, namespace
id, parent id (file id of the parent), user id of the owner
that owns this file, file
type, name, mime type of the primary stream attached to this file, file size,
creation date of the file, modification date, thumbnail and preview. Thumbnail
and preview are the file ids of the extra stream that represents thumbnai
l and
preview of the file respectively. General file types are 0
-
Normal file, 1
-
Directory,
2
-
Extra stream and 3
-
Symbolic link.

The main
Pogoplug

APIs

[
1
3
] used for implementing are given in the table below:
















27


METHOD

INPUT

OUTPUT

DESCRIPTION

loginUser

Email id,

Password

Validation token,
user object

Authenticates a user by email and
password and returns a validation
token
.

listServices:

Validation

Token,
device Id

Sequence of
service objects,

Lists all the services available to a
user exp
osed by a specific device

searchFiles:

Validation
token,
search
criteria

Page offset,
Count, sequence
of file objects

Search an entire service based on
some criteria.


listFiles:

Validation
token,
device Id,
service Id

Page offset,
Count, sequence
of
file objects

List the contents of some
directory, namespace, or service in
a paginated fashion.

createFile

Validation
token,
device Id,
service Id,

file name

File object

Creates a new child file or
directory inside a parent directory.
The newly created fi
le will be
empty, and data can be written to
using the data stream
API.


Table
4
: Pogoplug APIs

28



4.2

Android APIs

Section
3.1

described high level architecture of the Cloud Media player app. Various
classes described in section
3.1

have to interact with Android platform in order to do
things like displaying content on the screen, accepting user input, playing audio/video
etc. This is achieved using Android APIs

[14]
.

Th
e Android platform provides a framework API that applications can use to interact
with the underlying Android system. The framework API consists of:



A core set of packages and classes



A set of XML elements and attributes for declaring a manifest file



A set

of XML elements and attributes for declaring and accessing resources



A set of Intents



A set of permissions that applications can request, as well as permission
enforcements included in the system








29



API Method

Input

Output

Description

setContentView

Layout

None

Sets view to indicated
layout

getIntent

None

intent

Returns intent

Intent.
getStringExtra

None

Argument
String

Returns argument
string

findViewById

widget

Widget ID

Returns widget ID for
specified widget

MediaPlayer.
setDataSource

URL

None

Sets specified URL as
media data source

MediaPlayer.
prepare

None

None

Prepare data source
for media streaming

startActivity

Activity

None

Start specified activity

JSONArray.getJSONObject

String

JSONObject

Get JSONObject that
matches the specified
string

BitmapFactory.decode

URI

Bitmap

Decode image file
specified by URI and
return bitmap


Table
5
: Android APIs

30



4.3

Android client

The main features provided by the Media Cloud App are streaming the audio and

video
files from the cloud, displaying the images stored on the cloud, slideshow of the stored
images, and e
-
radio. The app also uses file management for all these files.

The main
functionalities of the android client are as given below:

1.

Provide an UI for

the user to log in to access files on the cloud.

2.

User interface for showing the files and folders stored on the cloud.

3.

Music player for playing audio files and for radio

4.

Image viewer for playing the slide show and for displaying the image files

5.

Video
player for streaming video files

6.

UI for uploading the files from the android device to the cloud


4.3.1

Login Screen

Source Files: LoginScreenActivity.java, login.xml

The screenshot in
Figure
6

shows the user interface for log in. User needs to provide an
email id and password to access the storage. The
Pogoplug

API loginUser is used to
authenticate the user. The user has access to
all the stored files once he signs in the
application. Appropriate error messages are given in case the log in is unsuccessful.

31



Figure
6
: Login Screen


4.3.2

Main Screen

Source Files: UserScreenActivity.java,
userscreen.xml

Once the us
er login is successful, main screen of Cloud Media app is presented
to the
user.
Figure
7

shows the main screen of Cloud Media app. As shown, this figu
re allows
user to select one of various functions supported by the app, such as image viewer, audio
player etc. Appropriate handlers are called to take action depending on the user selection.
The Pogoplug API “listServices” is used before main screen is pr
esented to the user.


32



Figure
7
: Main Screen


4.3.3

File View

Source Files: FileScreenActivity.java, filescreen.xml

Figure
8

shows the file and directory listing.
This screen is displayed when user selects
File Viewer in the main screen.
Appropriate
Activities

are called to take action depending
on the user selecti
on. The
Pogoplug

API listServices and listFiles are mainly used to
show the files/directory listing.


33




Figure
8
: File view


4.3.4

Music player

Source Files: AudioPlayerActivity.java, RadioScreenActivity.java, audioplayer.xml,
radio.xml

Figure
9

shows the audio
/radio

player for playing the music files.
To play audio, the user
can access the Music folder and select the file to play. Alternatively, user can click on
Radio and songs fro
m the Music folder will be played in a random order.

34


The player has different controls such as pause, next track, previous track, shuffle, repeat,
stop etc. In case of Radio only stop, pause and next track buttons are
provided
.



(A)


(B)

Figure
9
: (A)
-

Audio player screen
, (B)


Radio player screen


4.3.5

Image
V
iewer

Source Files: ImageViewerActivity.java, SlideShowActivity.java, imageviewer.xml,
slideshow.xml

Figure
10

is the screen shot for the image viewer. To view the images user can select
from Image folder or Slide show option. If the user choose to use the image folder, he/she
needs to select each file manually, whereas in slide show mode, all the images are
35


displa
yed at small interval. The images are scaled before displaying, to fit the android
device.





(A)








(B)

Figure
10
:
(A)
-

Image diaglog box
, (B)


Loaded image


4.3.6

Video player

Source Files:
VideoPlayerActivity.java, videoplayer.xml

Android API has video view control to enable video streaming. Path of the video file is
set and media controller is set for this videoview. Video streaming starts once this video
view is brought into focus.

36



4.3.7

File
Uploading

Source Files:

File
Upload
er
Activity.java,
file
upload
er
.xml

The user has the ability to upload file from the android device to the cloud. This
functionality makes use of
Pogoplug

API createFile to achieve the goal.

A dialog box is
used to indicate file upload progress.


Figure
11
: File uploading

37


Chapter 5

PERFORMANCE EVALUATION

The main advantage of Media Cloud app is in the ease of use with which users can access
data stored in cloud. As
discussed in Chapter 2, performance of any cloud computing
system is characterized by

[9, 16
]
:

1.

Consistency: Ability of a computer
-
related hardware or software component
to consistently perform according to its specifications

2.

Availability: Ability of the sy
stem to perform work when it is expected to
perform work

3.

Partition Tolerance: Ability of the system to perform in the event of arbitrary
message loss or failure of part of the system

4.

Response Time:
T
ime taken
to complete
requested

operation

Media streaming

is highly sensitive to response time,
resulting in noticeable glitches,
interruptions during playback if response time is longer than can be tolerated. Response
time
is a function of network connection speed
, which itself is
dependent upon the
connection
technology and Radio signal strength. Following data was co
ll
ected to
evaluate performance of the Media Cloud app.

As shown in the table
6
, good connection speed of at least 3G or better is required to
provide good quality audio/video playback.

Thus, we ca
n conclude that personal media
cloud application exhibits good consistency and availability as long as high speed internet
connectivity (better than 3G speeds) is guaranteed.

38


CONNECTION

BW LIMIT

MEDIA

OBSERVATION

EDGE

237 Kb/s

Audio/Video

Jittery audio,
no video

3G

384 Kb/s

Audio

Good quality MP3 playback

3G

384Kb/s

Video SD

Minimal interruptions

3G

384Kb/s

Video HD

Jittery video

4G

100Mb/s

Audio/Video

Good quality Audio/Video

Wi
-
Fi (G)

54Mb/
s

Audio/Video

Good quality Audio/Video

WiFi (N)

150Mb/s

Audio/Video

Good quality Audio/Video


Table
6
: Media Cloud app performance evaluation


Other aspect of performance is usability. Being a personal cloud, this system does not
face the issues associated with multi
-
user commercial cloud systems such as limited
space, recurring costs, limited content etc.




39


Chapter 6

CONCLUSION AND FUTURE WOR
K

The
personal media cloud
player app
lication provides a low cost
solution for

personal
media cloud. Moreover, the cost is not related to storage capacity and does not require
any monthly expenses, unlike commercial media clouds such as iCloud and Amazon
c
loud.

The app provides simple user interface and features like video streaming, photo
slideshow, e
-
Radio, file upload etc. that are not found in many of the cloud applications
available.

Based on performance studies we conclude that the personal media cl
oud application
exhibits good consistency and availability
characteristics
as long as high speed internet
connectivity (better than 3G speeds) is
avaialble
.


6.1

Future work

6.1.1

Playlist Management

This feature will allow users to specify playlist of media files

to be played.

6.1.2

File Sharing

Users will specify email IDs to share the files with and the app will setup the share.

40


6.1.3

Folder sync up

User will specify the folders that need to be sync’ed up with cloud. User will also specify
how frequently the folders should

be sync’ed up. Based on this information, the app will
periodically sync folders with the cloud.


41


APPENDIX

Source Code

********************************

AudioPlayerActivity.java

********************************

package com.android.cloudplayer;

import java
.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.StatusLine;

import org.apache.http.client.ClientPro
tocolException;

import org.apache.http.client.HttpClient;

import org.apache.http.client.methods.HttpGet;

import org.apache.http.impl.client.DefaultHttpClient;

import com.android.cloudplayer.ImageViewerActivity.BGThread;

import com.android.cloudplayer.Image
ViewerActivity.MyRunnable;

import android.R.drawable;

import android.app.Activity;

import android.app.ProgressDialog;

import android.content.Intent;

import android.graphics.Bitmap;

import android.graphics.Color;

import android.media.MediaPlayer;

import
android.media.MediaPlayer.OnCompletionListener;

import android.os.Bundle;

import android.os.Handler;

import android.util.Log;

import android.view.MotionEvent;

import android.view.View;

import android.view.View.OnTouchListener;

import android.widget.Button;

import android.widget.ImageView;

/**


*


* @author Prajakta Sarurkar


* This activity creates an UI for audio playback on the files.


*/


public class AudioPlayerActivity extends Activity

{


private static MediaPlayer mp;


private String devID, svcID
, mediaType;


private String valToken, userID;


private String fileReq;


private boolean pauseAction = false;

42



private static boolean playAction = false;


private boolean shuffleAction = false;


private boolean repeatAction = false;


private boolean filesDone = true;


private String [] fileIDArry;


private String [] fileNameArry;


private int fileIndex;


private int fileNum;


private int fileCnt = 0;


private Handler handler;


private Thread audioThread;


privat
e ProgressDialog prgDialog;





/** Called when the activity is first created. */


@Override


public void onCreate(Bundle savedInstanceState)


{



super.onCreate(savedInstanceState);



setContentView(R.layout.audioplayer);



Intent i = getInt
ent();





userID = i.getStringExtra("userID");


valToken = i.getStringExtra("valToken");


devID = i.getStringExtra("devID");


svcID = i.getStringExtra("svcID");


fileIndex = i.getIntExtra("fileIndex", 0);



fileNum = i.getIntExtra("fileNum", 1);


fileIDArry = new String[fileNum];


fileNameArry = new String[fileNum];


fileIDArry = i.getStringArrayExtra("fileID");


fileNameArry = i.getStringArrayExtra("fileName");





Log.i("AudioPlayer", "Entry");



Log.i("AudioPlayer", "userID "+userID);



Log.i("AudioPlayer", "valToken "+valToken);



Log.i("AudioPlayer", "devID "+devID);



Log.i("AudioPlayer", "svcID "+svcID);



Log.i("AudioPlayer", "fileID "+fileI
DArry[0]);



Log.i("AudioPlayer", "fileNum "+fileNum);



Log.i("AudioPlayer", "fileIndex "+fileIndex);




Button btnPlay = (Button) findViewById(R.id.btnPlay);



Button btnStop = (Button) findViewById(R.id.btnStop);



Button btnPause = (Butt
on) findViewById(R.id.btnPause);



Button btnNext = (Button) findViewById(R.id.btnNext);



Button btnPrev = (Button) findViewById(R.id.btnPrev);



Button btnRepeat = (Button) findViewById(R.id.btnRepeat);



Button btnShuffle = (Button) findView
ById(R.id.btnShuffle);


43







if (playAction)



{




mp.stop();




mp.release();




playAction = false;



}






if (fileNum == 1)




filesDone = true;






mp = new MediaPlayer();



Log.i("playAudio", "fileIndex " +
fileIndex + "Length " + fileIDArry.length);



Log.i("playAudio", "fileID " + fileIDArry[fileIndex]);




Log.i("AudioPlayer", "To play Audio");



// Create a handler to update the UI



handler = new Handler();






audioThread = new BGThread();



audioTh
read.start();



Log.i("Audio Thread ", audioThread.toString());



if (audioThread != null && audioThread.isAlive()) {




prgDialog = ProgressDialog.show(this, "Audio Player", "Loading audio");



}








//playAudio();







mp.setOnCompletionList
ener(new OnCompletionListener()



{




@Override




public void onCompletion(MediaPlayer mp)




{





if (filesDone)





{






mp.release();






playAction = false;






finish();





}





else





{






getNextPlayIndex();






playAudio();





}




}



});




btnNext.setOnTouchListener(new OnTouchListener ()

44




{




@Override



public boolean onTouch(View v, MotionEvent event)



{





Log.i("NextB", "playAction "+playAction);



if (event.getAction() == MotionEvent.ACTION
_DOWN && playAction)



{




getNextIndex();




playAudio();



}



return true;



}



});






btnPrev.setOnTouchListener(new OnTouchListener ()



{








@Override



public boolean onTouch(View v, MotionEvent event)



{





Log.i("PrevB", "playAction "+playAction);



if (event.getAction() == MotionEvent.ACTION_DOWN && playAction)



{




getPrevIndex();




playAudio();



}



return true;



}



});






btnRepeat.setOnTouchListener(new OnTouchListener ()



{




@Override



public boolean onTouch(View v, MotionEvent event)



{





Log.i("RepeatB", "playAction "
+playAction);



if (event.getAction() == MotionEvent.ACTION_DOWN && playAction)



{




repeatAction = !repeatAction;




if (repeatAction)




{





filesDone = false;






Log.i("Chan
ging color ", "Magenta");

//




btnRepeat.setEnabled(true);




}

//



else

//




btnRepeat.setEnabled(false);



}



return true;



}

45




});



btnShuffle.setOnTouchListener(new
OnTouchListener ()



{




@Override



public boolean onTouch(View v, MotionEvent event)



{





Log.i("ShuffleB", "playAction "+playAction);



if (event.getAction() == MotionEvent.ACTION_DOWN && playAction)



{




shuffleAction = !shuffleAction;



}



return true;



}



});






btnPause.setOnTouchListener(new OnTouchListener()



{




@Override



public boolean onTouch(View v, MotionEvent event)



{





Log.i("PauseB", "playAction "+playAction);



if (event.getAction() == MotionEvent.ACTION_DOWN && playAction)



{




pauseAction = !pauseAction;




if (pauseAction)





mp.pause();




else





mp.start();



}



return true;



}



});






btnStop.setOnTouchListener(new OnTouchListener()



{




@Override



public boolean onTouch(View v, MotionEvent event)



{





Lo
g.i("StopB", "playAction "+playAction);



if (event.getAction() == MotionEvent.ACTION_DOWN && playAction)



{






mp.release();






playAction = false;






finish();



}



return true;



}



});







btnPlay.setOnTouchListener(new OnTouchListener()

46




{





@Override



public boolean onTouch(View v, MotionEvent event)



{




Log.i("PlayB", "playAction "+playAction);



if (event.getAction() == MotionEvent.ACTION_DOWN)



{




if (!playAction)




{





mp = new MediaPlayer();





playAudio();




}




else if (playAction & pauseAction)




{





mp.start();





pauseAction = false;




}



}




return true;



}



});


}




/**



* Start streaming Audio file from requested location



*/


private void playAudio ()


{



Log.i("playAudio", "fileIndex " + fileIndex + "Length ");



Log.i("playAudio", "fileID " + fileIDArry[fileIndex]);




try



{




mp.reset();




mp.setDataSource("http://service.pogoplug.com/svc/files/"+valToken+"/"+devID+





"/"+svcID+"/"+fileIDArry[fileIndex]+"/strm");




mp.prepare();




mp.start();




playAction = true;



}



catch (IllegalArgumentException e)



{




e.printStackTrace();



}



catch (IllegalStateException e)



{




e.printStackTrace();



}



catch (IOE
xception e)

47




{




e.printStackTrace();



}



}




/**



* Get Previous file



*/


private void getPrevIndex ()


{



if (fileNum > 1)



{




if (shuffleAction)





fileIndex = (((int) (Math.random()*1000)) % fileNum);




else





fileIndex = (fileIndex
-

1) % fileNum;






}


}



/**



* Get Next file



*/


private void getNextPlayIndex ()


{



if (fileNum > 1)



{




if (shuffleAction)





fileIndex = (((int) (Math.random()*1000)) % fileNum);




else





fileIndex = (fileIndex + 1) % fileNum;




}






if

(!repeatAction)




fileCnt ++;






if (fileCnt == fileNum)




filesDone = true;





}




private void getNextIndex ()


{



if (fileNum > 1)



{




if (shuffleAction)





fileIndex = (((int) (Math.random()*1000)) % fileNum);




else





fileIndex =
(fileIndex + 1) % fileNum;






}

48



}




/**



* Thread for diaglog



*/


public class BGThread extends Thread


{



@Override



public void run()



{






playAudio();




handler.post(new MyRunnable());






}


}



public class MyRunnable implements Runna
ble


{



public void run()



{




//imageView.setImageBitmap(imgBitmap);




prgDialog.dismiss();



}


}


}



********************************

FileScreenActivity.java

********************************

package com.android.cloudplayer;


import
org.json.JSONArray;


import android.app.Activity;

import android.os.Bundle;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.util.ArrayList;

import java.util.HashMap;

impor
t java.util.Map;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.StatusLine;

import org.apache.http.client.ClientProtocolException;

49


import org.apache.http.client.HttpClient;

import
org.apache.http.client.methods.HttpGet;

import org.apache.http.impl.client.DefaultHttpClient;

import org.json.JSONArray;

import org.json.JSONException;

import org.json.JSONObject;


import android.app.ListActivity;

import android.content.Intent;

import andr
oid.os.Bundle;

import android.util.Log;

import android.view.Menu;

import android.view.MenuInflater;

import android.view.MenuItem;

import android.view.View;

import android.widget.AdapterView;

import android.widget.AdapterView.OnItemClickListener;

import and
roid.widget.Button;

import android.widget.ListView;

import android.widget.SimpleAdapter;

import android.widget.TextView;

import android.widget.ArrayAdapter;

import android.widget.Toast;


/**


*


* @author Prajakta Sarurkar


* This activity creates an UI f
or displaying all the directories and files.


* Appropriate action is taken in case the user clicks on a directory or file


* depending on the type of the file.


*/


public class FileScreenActivity extends Activity

{


//private JSONArray svcArr;


private
String devID, svcID, parentID, sortCrit;


private String valToken, userID;


private JSONArray fileArr;


private String fileReq;


private SimpleAdapter adapter;


private ListView fileListView;


private ArrayList <Map<String,String>> fileList;


private static String searchCrit;


private String [] fileID;


private String [] fileName;


private int fileSize;






/** Called when the activity is first created. */


@Override

50



public void onCreate(Bundle savedInstanceState)



{





super.onCreate(savedInstanceState);


setContentView(R.layout.filescreen);




TextView txtUserID = (TextView) findViewById(R.id.txtUserID);


Intent i = getIntent();


userID = i.getStringExtra("userID");


Log.i("User ID in FileScreen", userID);


txtUserID.setText(userID);




valToken = i.getStringExtra("valToken");


devID = i.getStringExtra("devID");


svcID = i.getStringExtra("svcID");


parentID = i.getStringExtra("parentID");


sortCrit = i.getStringExtra("sortcrit");


searchCrit = i.getStringExtra("searchCrit");




try


{



if(!searchCrit.equals(""))




fileReq =
"http://service.po
goplug.com/svc/api/json/searchFiles?searchcrit=mediatype+=+" +searchCrit+





"&valtoken="+valToken+"&serviceid="+svcID +
"&deviceid="+devID;



else if(parentID.equals(""))




fileReq = "http://service.pogoplug.com/svc/api/json/listFiles?sort
crit=" +sortCrit+






"&valtoken="+valToken+"&deviceid="+devID+"&serviceid="+svcID;



else




fileReq = "http://service.pogoplug.com/svc/api/json/listFiles?sortcrit=" +sortCrit+






"&valtoken="+valToken+"&deviceid="+devID+"&s
erviceid="+svcID







+"&sortcrit=+type&parentid="+parentID;




Log.i("fileReq", fileReq);




String fileResp = getHTTPResponse(fileReq);




Log.i("fileResp", fileResp.toString());




JSONObject fileObj = new JSONObject (fileResp);




Log.i
("Back from buildData", "BuildData");




fileArr = fileObj.optJSONArray("files");








fileList = buildData();




Log.i("Back from buildData","size "+fileList.size());









fileListView = (ListView) findViewById(R.id.listView1);




String[] from = { "fileName", "fileType" };




int[] to = { android.R.id.text1, android.R.id.text2 };





adapter = new SimpleAdapter(this, fileList,






android.R.layout.simple_list_item_2, from, to);




fileListView.setAdapter(adapter);

51






fileListView.setOnItemClickListener(new OnItemClickListener()




{





@Override





public void onItemClick(AdapterView<?> parent, View view, int pos, long id)





{






try






{







JSONObject jObj = fileArr.getJSONObject(po
s);







String parentID;







if (jObj.getString("type").equals("1"))







{








parentID = jObj.getString("fileid");







fileReq = "http://service.pogoplug.com/svc/api/json/listFiles?sortcrit="
+sortCrit+









"&valtoken="+valToken+"&deviceid="+devID+"&serviceid="+svcID










+"&sortcrit=+type&parentid="+parentID;







Log.i("fileReq", fileReq);







String fileResp = getHTTPResponse(fileReq);







Log.i("fileResp", fileRe
sp.toString());







JSONObject fileObj = new JSONObject (fileResp);







clrData(fileArr.length());







adapter.notifyDataSetChanged();







//Log.i("Back from buildData", "BuildData");







fileArr
= fileObj.optJSONArray("files");







updateData();












adapter.notifyDataSetChanged();







}







else if (jObj.getString("type").equals("0"))







{








fileID = new String[fileArr.length()];








file
Name = new String[fileArr.length()];








int fileIndex = 0;








int fileNum = 1;








fileID[0] = jObj.getString("fileid");








fileName[0] = jObj.getString("filename");








fileSize = jObj.getInt("size");









Log.i("Mime Type",
jObj.getS
tring("mimetype"));








if
(jObj.getString("mimetype").equals("audio/mpeg"))








{









if (searchCrit.equals("audio"))









{










fileNum = fileArr.length();










Log.i("toAudio", "Crit equals
Audio");

52











fo
r (int index = 0;index <
fileNum;index ++)










{











fileID[index] =
fileArr.getJSONObject(index).getString("fileid");