SlideShare uma empresa Scribd logo
1 de 54
Android Media Player Development
Suyash Gupta
Android Developer
Talentica Software
Agenda
1.Introduction
2.Characteristics of Video streams
3.Android Media Player Development
4.Advanced Media Player Development
• Video - Most Popular and common way of entertainment.
• Boom in mobile market in past 5 years.
• 3g services revolutionized the telecommunication industry.
1. Introduction
1) Video - Journey So Far
● Video technology was first developed for (CRT) televisions.
● Video recorders were sold for $50,000 in 1956, and videotapes
cost $300 per one-hour reel.
● Sony introduced VCR in 1971.
● Then came CD's in 1997.
● Followed by blue ray disc in 2006.
● Computers to capture, store, edit and transmit video clips.
● Smartphones users grew to a increase to a limit of 80%.
● Video watching became very user friendly.
Note: In Real-time entertainment the major share is made by YouTube, Netflix and Pandora.
2. Characteristics of Video Streams
a) Frame rate
b) Interlaced VS progressive
c) Aspect ratio
d) Color depth
e) Digital video
f) Video compression method (digital only)
g) Containers for Codecs
a) Frame Rate
The number of still pictures per unit of time of video.
a) Frame Rate
• To identify each frame individually min 10-12 FPS.
• Early silent films had a frame rate from 14 to 24 FPS but it
was perceived as jerky motion.
• There are three main frame rate standards in
the TV and digital cinema business: 24p, 25p, and 30p.
• 48p is a progressive format and is currently being trailed in
the film industry.(The Hobbit)
b) Video Can Be Interlaced/Progressive
Interlaced video:
● Every frame has horizontal lines.
● Each frame is divided into 2 fields.
● Odd field and even field.
● Interlacing is a technique of doubling the FR within the
limitations of a narrow bandwidth.
● Image Detail is sacrificed.
b) Interlaced & Progressive Frames
Odd Field Even Field
b) Interlaced Video Fields
b) Interlaced Video Frame
● Progressive is a method for displaying, storing or transmitting
moving images.
● Each Frame resembles an image.
● Progressive scan is used in most CRTs used as computer
Monitors.
● It is also becoming increasingly common in high-end Television
equipment, which is often capable of performing de-interlacing
so that Interlaced video can still be viewed.
b) Progressive Video
b) Progressive Video Frame
Advantages of progressive scan include:
1. Better quality of video.
2. No flickering of narrow horizontal patterns.
3. Simpler video processing equipment.
4. Easier compression than interlaced.
b) Progressive Video
c) Aspect ratio
●
Aspect ratio describes the dimensions of video screens.
●
Traditional television screen is 4:3.
●
High definition televisions(720p and 1080p) 16:9.
●
AR 1.85:1 and 35 mm US and UK widescreen standard for
theatrical film.
c) Some Common Aspect Ratios
d) Color Depth
The number of bits used to indicate the color of a single pixel, in a
video frame buffer.
Bit is a storage value of a pixel.
1-bit color (2^1 = 2 colors): monochrome, black and white
2-bit color (2^2 = 4 colors): CGA, gray-scale early NeXTstation,
color Macintoshes ect.
3-bit color (2^3 = 8 colors)
4-bit color (2^4 = 16 colors):
d) Color Depth
6-bit color (2^6 = 64 colors):
8-bit color (2^8 = 256 colors): most early color Unix workstations,
VGA at low resolution, video games.
16-bit color (2^16 = 32768 colors): some Silicon Graphics systems
True color supports 24-bit for three RGB colors.
d) Color Depths Examples
2 bits (4 colors)
4 bits (16 colors)
1 bit (2 colors)
d) Color Depths
24 bits (16,777,216
colors, "truecolor")
8 bits (256 colors)
e) Digital Video
● Analog video stores video signal on magnetic tape.
● When copies are made of an Analog signal, degradation is
introduced due to loss of video signal in the copying.
● Whereas in digital data every bit has a binary value.
● So copying is 100% precise.
Analog Solution to Video Recording Digital Video Storage Medium
e) Size of Raw Digital Video
Digital Video in its raw form can be huge.
An example video can have a duration of (3600sec), a frame size
of 640x480 (WxH) at a color depth of 24bits and a frame rate of
25fps.
● pixels per frame = 640 * 480 = 307,200
● bits per frame = 307,200 * 24 = 7,372,800 = 7.37Mbits
● bit rate (BR) = 7.37 * 25 = 184.25Mbits/sec
● video size (VS) = 184Mbits/sec * 3600sec = 662,400Mbits =
82,800Mbytes = 82.8Gbytes
e) Issues
Leads to two interrelated problems:
1) Large storage requirements.
2) High Bandwidth requirement during playback and recording.
f) Video Compression
1. Conversion of data to a format that requires fewer bits.
2. The inverse process is known as decompression.
3. Decompression may or may not yield an exact copy of the
original data.
f) Video Codec
A codec is a compression algorithm, used to reduce the size of a
stream. The compression is usually lossy.
•
Lossless compression: It is a class of data compression algorithms
that allows the original data to be perfectly reconstructed from
the compressed data.
•
“Lossy" compression is a data encoding method that compresses
data by discarding (losing) some of it.
80%
compression
90%
compression
96%
compression
f) Comparison of Lossy Compression
MPEG-1(1993)(Moving Pictures Expert Group)
[Old, supported by everything (at least up to 352x240)]
MPEG-2 codecs
A good quality of compression. This is what is used for DVD.
MPEG-4 (1998)AVC (DivX codec)
A good quality compression with maintaining the quality of
video.
H.263/MPEG-4 Part 2 codecs
DivX Pro Codec: Compresses video down to very small file sizes-
excellent for web use but loses quality.
f) Different Codecs
That's why not used for the television purpose
Xvid: Free/open-source implementation of MPEG-4 ASP,
originally based on the OpenDivX project. Similar as DivX Pro
Codec.
FFmpeg MPEG-4: Open-source libavcodec codec library
Used by default for decoding or encoding in many open-source
video players such as MXPlayer, VLC, MPlayer and GStreamer.
WMV (Windows Media Video): Microsoft's family of proprietary
video codec designs including WMV 7, WMV 8, and WMV 9.
Google (On2) codecs:
VP6, VP6-E, VP6-S, VP7, VP8 VP9 : Proprietary high definition
video compression formats and codecs developed
by On2 Technologies
g) Containers for Codecs
The container describes the structure of the file: where the
various pieces are stored and how they are made.
I) AVI (standard Microsoft Win container)
(mostly used in digital cameras)
II) MOV (standard QuickTime container)
Carries the widest range of codecs
III) MPEG-2 TS (acronym of Transport Stream,
standard container for digital broadcasting)
g) Containers for Codecs
IV) MP4 (standard container for the MPEG-4 multimedia portfolio)
V) RealMedia (standard container for RealVideo and RealAudio)
VI) 3gp (used by many mobile phones)
3. Android Media Player
a) Android supported formats
b)Media player API and Sample Code
c)Limitations of Media Player
Type Format /
Codec
Encoder Decoder Details Supported File
Type(s) /
Container
Formats
Video H.263 • • • 3GPP (.3gp)
• MPEG-4 (.mp4)
H.264 AVC •
(Android 3.0+)
• Baseline Profile
(BP)
• 3GPP (.3gp)
• MPEG-4 (.mp4)
• MPEG-TS (.ts,
AAC audio only,
not seekable,
Android 3.0+)
MPEG-4 SP • 3GPP (.3gp)
VP8 •
(Android 4.3+)
•
(Android 2.3.3+)
Streamable
only in Android
4.0 and above
• WebM (.webm)
• Matroska
(.mkv, Android
4.0+)
3. a) Android supported formats
3. b) Media Player API
RecordPlayback
Audio / Video
android.media.MediaPlayer android.media.MediaRecorder
b) Playback: MediaPlayer Basics
Play Media From:
• Resource Folder
• File System Path
• URL
Basically
• Create new instance of MediaPlayer
• Call prepare()
• Call start()
b) Playback View
Playing a video File
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<SurfaceView
android:id="@+id/surfaceView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/seekBar1"
android:layout_alignParentTop="true"
android:layout_weight="0.67" />
</RelativeLayout>
b) Layout View
Create Using:
• URI
• Resource ID
States:
• Start
• Prepare
• Pause
• Release
• Reset
• SeekTo
• Stop
• Error
Get:
• Position
• Duration
• isPlaying
Set:
Output Display
Looping
• Data Source
• Wake Mode
Listeners:
• Buffering Update
• Completion
• Error
• When Prepared
Inherits from
java.lang.Object
b) MediaPlayer Class
public class MainActivity extends Activity implements SurfaceHolder.Callback,
OnPreparedListener, OnErrorListener, OnInfoListener {
MediaPlayer mediaPlayer;
SurfaceHolder surfaceHolder;
SurfaceView playerSurfaceView;
String videoSrc = "rtsp://v6.cache1.c.youtube.com/CjYLENy73wIaLQkDsLHya4-
Z9hMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYKX4k4uBjbOiUQw=/0/0/0/video.3gp";
//String dataSrc = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
//int resId = R.raw.sample;//.mp4
//int String dataSrc = "/sdcard/music/sample_music.mp3";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
playerSurfaceView = (SurfaceView) findViewById(R.id.playersurface);
surfaceHolder = playerSurfaceView.getHolder();
surfaceHolder.addCallback(this);
}
b) Activity Code
@Override
public void surfaceCreated(SurfaceHolder arg0) {
try {
mediaPlayer = new MediaPlayer();
mediaPlayer.setDisplay(surfaceHolder);
mediaPlayer.setDataSource(videoSrc);
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.setOnErrorListener(this);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.prepare();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
b) Activity Code
@Override
public void onPrepared(MediaPlayer mp) {
mediaPlayer.start();
}
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.e("MainActivity", "what="+what+" extra="+extra);
return false;
}
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
Log.i("MainActivity", "what="+what+" extra="+extra);
return false;
}
b) Activity Code
Media Player State Diagram
c) Limitations of Media Player
• Any time media player changes state, check before selecting any
action or you may fall into IllegalStateException.
• Error when the orientation of screen is change, even if you manage
the tag screenOrientation=“orientation” in manifest.xml
• When activity goes in background and MediaPlayer is playing, even if
you have handled onPause and onResume in some devices it goes to
error state.
• There are 30 to 34 types of possible error starting from -1 to -34.
For e.g. Error: the video container is not valid for progressive
playback (-32);
Error due to resource being in wrong state to handle request (-14)
Error due to general data processing(-18)
c) Limitations of Media Player
• public static void playMusic(int id)
{ // Not a good practice
MediaPlayer mediaPlayer = MediaPlayer.create(context, id);
mediaPlayer.setLooping(true); mediaPlayer.start();
} // Here the media player will be removed by GC even if it is
in play mode.
• The error value (1, -2147483648), the '1' value corresponds to
the constant in MediaPlayer.MEDIA_ERROR_UNKNOWN. (This
might happen)
-2147483648 corresponds to hexadecimal 0x80000000 which is
defined as UNKNOWN_ERROR
4. Advanced Media Player Development
• Customization Features
• Benefits of Customization
• Drawbacks
• FFMPEG Library
We can Customize the Media Player and achieve :
We can enhance security.
a) Playing video in chunks
b) Prevent video from getting stolen.
c) Encrypt the InputStream with Cipher.
• Real Time manipulation.(Play ads in between)
• Adaptive Streaming.(Configurable bandwidth)
• Multi Format Playing.(discussed later)
a) Customization Features
• Your video content is secure.
• Easily applicable to other java platforms too for e.g. J2ME
• Saved video can be played only by our media player.
• Configurable bandwidth according to network speed.
• Since playback is chunk by chunk you can show video ads in
between them too.
• Event handling during playback is possible for e.g. at what point
the user stops the video or how much percentage watched.
b) Benefits of Customization
• Decoding of Android media player is bad, may fall into lot of
errors and you might not get possible solution anywhere.
(Limited number of file formats)
• The total chunk playback duration and the clip playback
duration should match or the player will again throw errors
like ChunkNotFound (Custom exception).
c) Drawbacks
d) FFMPEG Library
• Almost every android phone user is friendly with MX Player
which is a pretty famous player.
• MX Player is build using FFMpeg library which we will discuss
later.
• It is user-friendly, plays almost all formats and possesses great
build-in features.
• Plays almost every movie files including .3gp .avi .divx .f4v
.flv .mkv .mp4 .mpeg .mov .vob .wmv .webm .xvid and many
more
• Hardware decoding (with h/w+ decoder)
• Processor optimization
• High speed rendering for ARM® NEON™ compliant
processors.
• Provides processor specific Codecs including Tegra 2
processor.
• Move forward/backward (Optional)
• Aspect ratio selection
d)Features of MX Player
Following conditions are required to run included shell script:
•Linux or Cygwin
•Latest Google NDK
Download ffmpeg source code
1.In config-ffmpeg.sh, change "NDK" variable to point NDK path.
2.Add this line NDK=$HOME/Desktop/adt/android-ndk-r9
3.In build.sh, change "MAKE" variable to point ndk-build script of
NDK directory.
4.Run the shell scripts by command ./build.sh
5.The build can take a while to finish depending on your
computer speed.
6.Make ffmpeg Libraries available for Your Projects
How to build FFmpeg for Android
References
Video Characteristics:
http://en.wikipedia.org/wiki/Video
Android Developer Site:
http://developer.android.com/reference/android/media/MediaPlayer.html
FFMPEG Build:
http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/
Thank You!

Mais conteúdo relacionado

Mais procurados (20)

Mp3 player
Mp3 playerMp3 player
Mp3 player
 
Android Media player
Android Media playerAndroid Media player
Android Media player
 
Java Media Player thorugh JMF
Java Media Player thorugh JMFJava Media Player thorugh JMF
Java Media Player thorugh JMF
 
Getting started with android programming
Getting started with android programmingGetting started with android programming
Getting started with android programming
 
[Android] Multimedia Programming
[Android] Multimedia Programming[Android] Multimedia Programming
[Android] Multimedia Programming
 
Lec001
Lec001Lec001
Lec001
 
Droidcon2013 miracast final2
Droidcon2013 miracast final2Droidcon2013 miracast final2
Droidcon2013 miracast final2
 
Android (Types, Feature,Application etc..)
Android (Types, Feature,Application etc..)Android (Types, Feature,Application etc..)
Android (Types, Feature,Application etc..)
 
What & How to Customize Android?
What & How to Customize Android?What & How to Customize Android?
What & How to Customize Android?
 
Introduction to android (and mobile) game development
Introduction to android (and mobile) game developmentIntroduction to android (and mobile) game development
Introduction to android (and mobile) game development
 
An Advanced Mobile Media Player Using J2 Me
An Advanced Mobile Media Player Using J2 MeAn Advanced Mobile Media Player Using J2 Me
An Advanced Mobile Media Player Using J2 Me
 
Android Car Music Player
Android Car Music PlayerAndroid Car Music Player
Android Car Music Player
 
Introduction to Andriod
Introduction to AndriodIntroduction to Andriod
Introduction to Andriod
 
Android ppt
Android pptAndroid ppt
Android ppt
 
B inggris
B inggrisB inggris
B inggris
 
What is operating system
What is operating systemWhat is operating system
What is operating system
 
Software (fundamentals)
Software (fundamentals)Software (fundamentals)
Software (fundamentals)
 
Android
AndroidAndroid
Android
 
Android
AndroidAndroid
Android
 
Software training report
Software training reportSoftware training report
Software training report
 

Destaque

3D Video Programming for Android
3D Video Programming for Android3D Video Programming for Android
3D Video Programming for AndroidYoss Cohen
 
Step by Step Mobile Optimization
Step by Step Mobile OptimizationStep by Step Mobile Optimization
Step by Step Mobile OptimizationGuy Podjarny
 
Delta++ Reducing The Size Of Android Application Updates
Delta++ Reducing The Size Of Android Application UpdatesDelta++ Reducing The Size Of Android Application Updates
Delta++ Reducing The Size Of Android Application UpdatesPapitha Velumani
 
Types Of Sentences Ppt
Types Of Sentences PptTypes Of Sentences Ppt
Types Of Sentences PptMarie Semrow
 
Sentence Structure Ppt
Sentence Structure PptSentence Structure Ppt
Sentence Structure Pptandycinek
 
Types Of Sentences
Types Of SentencesTypes Of Sentences
Types Of Sentencesmelissagkh
 

Destaque (7)

3D Video Programming for Android
3D Video Programming for Android3D Video Programming for Android
3D Video Programming for Android
 
Step by Step Mobile Optimization
Step by Step Mobile OptimizationStep by Step Mobile Optimization
Step by Step Mobile Optimization
 
Delta++ Reducing The Size Of Android Application Updates
Delta++ Reducing The Size Of Android Application UpdatesDelta++ Reducing The Size Of Android Application Updates
Delta++ Reducing The Size Of Android Application Updates
 
Types Of Sentences Ppt
Types Of Sentences PptTypes Of Sentences Ppt
Types Of Sentences Ppt
 
Sentence structure powerpoint
Sentence structure powerpointSentence structure powerpoint
Sentence structure powerpoint
 
Sentence Structure Ppt
Sentence Structure PptSentence Structure Ppt
Sentence Structure Ppt
 
Types Of Sentences
Types Of SentencesTypes Of Sentences
Types Of Sentences
 

Semelhante a Android Media Player Development

Industrial Technology Multimedia Video Theory Prelim Course
Industrial Technology Multimedia Video Theory Prelim CourseIndustrial Technology Multimedia Video Theory Prelim Course
Industrial Technology Multimedia Video Theory Prelim Coursejliang2145
 
simple video compression
simple video compression simple video compression
simple video compression LaLit DuBey
 
Chapter 6 : VIDEO
Chapter 6 : VIDEOChapter 6 : VIDEO
Chapter 6 : VIDEOazira96
 
Ch07_-_Multimedia_Element-Video_1_.ppt
Ch07_-_Multimedia_Element-Video_1_.pptCh07_-_Multimedia_Element-Video_1_.ppt
Ch07_-_Multimedia_Element-Video_1_.pptdjempol
 
02.m3 cms sys-req4mediastreaming
02.m3 cms sys-req4mediastreaming02.m3 cms sys-req4mediastreaming
02.m3 cms sys-req4mediastreamingtarensi
 
Video Compression Technology
Video Compression TechnologyVideo Compression Technology
Video Compression TechnologyTong Teerayuth
 
DIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesDIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesRasan Samarasinghe
 
Video Coding Standard
Video Coding StandardVideo Coding Standard
Video Coding StandardVideoguy
 
Image and Video formates
Image and Video formatesImage and Video formates
Image and Video formatesPrerak Shirpur
 
Mpeg4copy 120428133000-phpapp01
Mpeg4copy 120428133000-phpapp01Mpeg4copy 120428133000-phpapp01
Mpeg4copy 120428133000-phpapp01netzwelt12345
 
PowerPoint 97
PowerPoint 97PowerPoint 97
PowerPoint 97Videoguy
 
Week 4 LBSC 690 Information Technology
Week 4 LBSC 690 Information TechnologyWeek 4 LBSC 690 Information Technology
Week 4 LBSC 690 Information TechnologyVideoguy
 

Semelhante a Android Media Player Development (20)

Industrial Technology Multimedia Video Theory Prelim Course
Industrial Technology Multimedia Video Theory Prelim CourseIndustrial Technology Multimedia Video Theory Prelim Course
Industrial Technology Multimedia Video Theory Prelim Course
 
simple video compression
simple video compression simple video compression
simple video compression
 
Chapter 6 : VIDEO
Chapter 6 : VIDEOChapter 6 : VIDEO
Chapter 6 : VIDEO
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Ch07_-_Multimedia_Element-Video_1_.ppt
Ch07_-_Multimedia_Element-Video_1_.pptCh07_-_Multimedia_Element-Video_1_.ppt
Ch07_-_Multimedia_Element-Video_1_.ppt
 
Mm Unit 4
Mm Unit 4Mm Unit 4
Mm Unit 4
 
02.m3 cms sys-req4mediastreaming
02.m3 cms sys-req4mediastreaming02.m3 cms sys-req4mediastreaming
02.m3 cms sys-req4mediastreaming
 
Video Compression Technology
Video Compression TechnologyVideo Compression Technology
Video Compression Technology
 
Mm video
Mm videoMm video
Mm video
 
DIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesDIWE - Multimedia Technologies
DIWE - Multimedia Technologies
 
Video Coding Standard
Video Coding StandardVideo Coding Standard
Video Coding Standard
 
Image and Video formates
Image and Video formatesImage and Video formates
Image and Video formates
 
File Formats
File FormatsFile Formats
File Formats
 
Mpeg4copy 120428133000-phpapp01
Mpeg4copy 120428133000-phpapp01Mpeg4copy 120428133000-phpapp01
Mpeg4copy 120428133000-phpapp01
 
MPEG4 vs H.264
MPEG4 vs H.264MPEG4 vs H.264
MPEG4 vs H.264
 
Chapter 1 Video
Chapter 1 VideoChapter 1 Video
Chapter 1 Video
 
PowerPoint 97
PowerPoint 97PowerPoint 97
PowerPoint 97
 
Digital File Formats
Digital File Formats Digital File Formats
Digital File Formats
 
Week 4 LBSC 690 Information Technology
Week 4 LBSC 690 Information TechnologyWeek 4 LBSC 690 Information Technology
Week 4 LBSC 690 Information Technology
 
Video
VideoVideo
Video
 

Mais de Talentica Software

Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to AdvancedTalentica Software
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in ReactTalentica Software
 
Nodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternNodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternTalentica Software
 
Setting Up Development Environment For Google App Engine & Python | Talentica
Setting Up Development Environment For Google App Engine & Python | TalenticaSetting Up Development Environment For Google App Engine & Python | Talentica
Setting Up Development Environment For Google App Engine & Python | TalenticaTalentica Software
 
Connected World in android - Local data sharing and service discovery
Connected World in android - Local data sharing and service discoveryConnected World in android - Local data sharing and service discovery
Connected World in android - Local data sharing and service discoveryTalentica Software
 
Mobile App Monetization - Ecosystem & Emerging Trends
Mobile App Monetization - Ecosystem & Emerging TrendsMobile App Monetization - Ecosystem & Emerging Trends
Mobile App Monetization - Ecosystem & Emerging TrendsTalentica Software
 
Cross Platform Mobile Technologies
Cross Platform Mobile TechnologiesCross Platform Mobile Technologies
Cross Platform Mobile TechnologiesTalentica Software
 
Big Data Technologies - Hadoop
Big Data Technologies - HadoopBig Data Technologies - Hadoop
Big Data Technologies - HadoopTalentica Software
 
Continous Integration: A Case Study
Continous Integration: A Case StudyContinous Integration: A Case Study
Continous Integration: A Case StudyTalentica Software
 
Technology Challenges in Building New Media Applications
Technology Challenges in Building New Media ApplicationsTechnology Challenges in Building New Media Applications
Technology Challenges in Building New Media ApplicationsTalentica Software
 
Flex on Grails - Rich Internet Applications With Rapid Application Development
Flex on Grails - Rich Internet Applications With Rapid Application DevelopmentFlex on Grails - Rich Internet Applications With Rapid Application Development
Flex on Grails - Rich Internet Applications With Rapid Application DevelopmentTalentica Software
 

Mais de Talentica Software (20)

Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
 
Web 3.0
Web 3.0Web 3.0
Web 3.0
 
Remix
RemixRemix
Remix
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Nodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternNodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design Pattern
 
Node js Chapter-2
Node js Chapter-2Node js Chapter-2
Node js Chapter-2
 
Node.js Chapter1
Node.js Chapter1Node.js Chapter1
Node.js Chapter1
 
Micro Frontends
Micro FrontendsMicro Frontends
Micro Frontends
 
Test Policy and Practices
Test Policy and PracticesTest Policy and Practices
Test Policy and Practices
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Setting Up Development Environment For Google App Engine & Python | Talentica
Setting Up Development Environment For Google App Engine & Python | TalenticaSetting Up Development Environment For Google App Engine & Python | Talentica
Setting Up Development Environment For Google App Engine & Python | Talentica
 
Connected World in android - Local data sharing and service discovery
Connected World in android - Local data sharing and service discoveryConnected World in android - Local data sharing and service discovery
Connected World in android - Local data sharing and service discovery
 
Mobile App Monetization - Ecosystem & Emerging Trends
Mobile App Monetization - Ecosystem & Emerging TrendsMobile App Monetization - Ecosystem & Emerging Trends
Mobile App Monetization - Ecosystem & Emerging Trends
 
Cross Platform Mobile Technologies
Cross Platform Mobile TechnologiesCross Platform Mobile Technologies
Cross Platform Mobile Technologies
 
Big Data Technologies - Hadoop
Big Data Technologies - HadoopBig Data Technologies - Hadoop
Big Data Technologies - Hadoop
 
Big Data – Are You Ready?
Big Data – Are You Ready?Big Data – Are You Ready?
Big Data – Are You Ready?
 
Legacy modernization
Legacy modernizationLegacy modernization
Legacy modernization
 
Continous Integration: A Case Study
Continous Integration: A Case StudyContinous Integration: A Case Study
Continous Integration: A Case Study
 
Technology Challenges in Building New Media Applications
Technology Challenges in Building New Media ApplicationsTechnology Challenges in Building New Media Applications
Technology Challenges in Building New Media Applications
 
Flex on Grails - Rich Internet Applications With Rapid Application Development
Flex on Grails - Rich Internet Applications With Rapid Application DevelopmentFlex on Grails - Rich Internet Applications With Rapid Application Development
Flex on Grails - Rich Internet Applications With Rapid Application Development
 

Último

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Último (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Android Media Player Development

  • 1. Android Media Player Development Suyash Gupta Android Developer Talentica Software
  • 2. Agenda 1.Introduction 2.Characteristics of Video streams 3.Android Media Player Development 4.Advanced Media Player Development
  • 3. • Video - Most Popular and common way of entertainment. • Boom in mobile market in past 5 years. • 3g services revolutionized the telecommunication industry. 1. Introduction
  • 4. 1) Video - Journey So Far ● Video technology was first developed for (CRT) televisions. ● Video recorders were sold for $50,000 in 1956, and videotapes cost $300 per one-hour reel. ● Sony introduced VCR in 1971. ● Then came CD's in 1997. ● Followed by blue ray disc in 2006. ● Computers to capture, store, edit and transmit video clips. ● Smartphones users grew to a increase to a limit of 80%. ● Video watching became very user friendly.
  • 5. Note: In Real-time entertainment the major share is made by YouTube, Netflix and Pandora.
  • 6. 2. Characteristics of Video Streams a) Frame rate b) Interlaced VS progressive c) Aspect ratio d) Color depth e) Digital video f) Video compression method (digital only) g) Containers for Codecs
  • 7. a) Frame Rate The number of still pictures per unit of time of video.
  • 8. a) Frame Rate • To identify each frame individually min 10-12 FPS. • Early silent films had a frame rate from 14 to 24 FPS but it was perceived as jerky motion. • There are three main frame rate standards in the TV and digital cinema business: 24p, 25p, and 30p. • 48p is a progressive format and is currently being trailed in the film industry.(The Hobbit)
  • 9. b) Video Can Be Interlaced/Progressive Interlaced video: ● Every frame has horizontal lines. ● Each frame is divided into 2 fields. ● Odd field and even field. ● Interlacing is a technique of doubling the FR within the limitations of a narrow bandwidth. ● Image Detail is sacrificed.
  • 10. b) Interlaced & Progressive Frames Odd Field Even Field
  • 13. ● Progressive is a method for displaying, storing or transmitting moving images. ● Each Frame resembles an image. ● Progressive scan is used in most CRTs used as computer Monitors. ● It is also becoming increasingly common in high-end Television equipment, which is often capable of performing de-interlacing so that Interlaced video can still be viewed. b) Progressive Video
  • 15. Advantages of progressive scan include: 1. Better quality of video. 2. No flickering of narrow horizontal patterns. 3. Simpler video processing equipment. 4. Easier compression than interlaced. b) Progressive Video
  • 16. c) Aspect ratio ● Aspect ratio describes the dimensions of video screens. ● Traditional television screen is 4:3. ● High definition televisions(720p and 1080p) 16:9. ● AR 1.85:1 and 35 mm US and UK widescreen standard for theatrical film.
  • 17. c) Some Common Aspect Ratios
  • 18. d) Color Depth The number of bits used to indicate the color of a single pixel, in a video frame buffer. Bit is a storage value of a pixel. 1-bit color (2^1 = 2 colors): monochrome, black and white 2-bit color (2^2 = 4 colors): CGA, gray-scale early NeXTstation, color Macintoshes ect. 3-bit color (2^3 = 8 colors) 4-bit color (2^4 = 16 colors):
  • 19. d) Color Depth 6-bit color (2^6 = 64 colors): 8-bit color (2^8 = 256 colors): most early color Unix workstations, VGA at low resolution, video games. 16-bit color (2^16 = 32768 colors): some Silicon Graphics systems True color supports 24-bit for three RGB colors.
  • 20. d) Color Depths Examples 2 bits (4 colors) 4 bits (16 colors) 1 bit (2 colors)
  • 21. d) Color Depths 24 bits (16,777,216 colors, "truecolor") 8 bits (256 colors)
  • 22. e) Digital Video ● Analog video stores video signal on magnetic tape. ● When copies are made of an Analog signal, degradation is introduced due to loss of video signal in the copying. ● Whereas in digital data every bit has a binary value. ● So copying is 100% precise. Analog Solution to Video Recording Digital Video Storage Medium
  • 23. e) Size of Raw Digital Video Digital Video in its raw form can be huge. An example video can have a duration of (3600sec), a frame size of 640x480 (WxH) at a color depth of 24bits and a frame rate of 25fps. ● pixels per frame = 640 * 480 = 307,200 ● bits per frame = 307,200 * 24 = 7,372,800 = 7.37Mbits ● bit rate (BR) = 7.37 * 25 = 184.25Mbits/sec ● video size (VS) = 184Mbits/sec * 3600sec = 662,400Mbits = 82,800Mbytes = 82.8Gbytes
  • 24. e) Issues Leads to two interrelated problems: 1) Large storage requirements. 2) High Bandwidth requirement during playback and recording.
  • 25. f) Video Compression 1. Conversion of data to a format that requires fewer bits. 2. The inverse process is known as decompression. 3. Decompression may or may not yield an exact copy of the original data.
  • 26. f) Video Codec A codec is a compression algorithm, used to reduce the size of a stream. The compression is usually lossy. • Lossless compression: It is a class of data compression algorithms that allows the original data to be perfectly reconstructed from the compressed data. • “Lossy" compression is a data encoding method that compresses data by discarding (losing) some of it.
  • 28. MPEG-1(1993)(Moving Pictures Expert Group) [Old, supported by everything (at least up to 352x240)] MPEG-2 codecs A good quality of compression. This is what is used for DVD. MPEG-4 (1998)AVC (DivX codec) A good quality compression with maintaining the quality of video. H.263/MPEG-4 Part 2 codecs DivX Pro Codec: Compresses video down to very small file sizes- excellent for web use but loses quality. f) Different Codecs
  • 29. That's why not used for the television purpose Xvid: Free/open-source implementation of MPEG-4 ASP, originally based on the OpenDivX project. Similar as DivX Pro Codec. FFmpeg MPEG-4: Open-source libavcodec codec library Used by default for decoding or encoding in many open-source video players such as MXPlayer, VLC, MPlayer and GStreamer.
  • 30. WMV (Windows Media Video): Microsoft's family of proprietary video codec designs including WMV 7, WMV 8, and WMV 9. Google (On2) codecs: VP6, VP6-E, VP6-S, VP7, VP8 VP9 : Proprietary high definition video compression formats and codecs developed by On2 Technologies
  • 31. g) Containers for Codecs The container describes the structure of the file: where the various pieces are stored and how they are made. I) AVI (standard Microsoft Win container) (mostly used in digital cameras) II) MOV (standard QuickTime container) Carries the widest range of codecs III) MPEG-2 TS (acronym of Transport Stream, standard container for digital broadcasting)
  • 32. g) Containers for Codecs IV) MP4 (standard container for the MPEG-4 multimedia portfolio) V) RealMedia (standard container for RealVideo and RealAudio) VI) 3gp (used by many mobile phones)
  • 33. 3. Android Media Player a) Android supported formats b)Media player API and Sample Code c)Limitations of Media Player
  • 34. Type Format / Codec Encoder Decoder Details Supported File Type(s) / Container Formats Video H.263 • • • 3GPP (.3gp) • MPEG-4 (.mp4) H.264 AVC • (Android 3.0+) • Baseline Profile (BP) • 3GPP (.3gp) • MPEG-4 (.mp4) • MPEG-TS (.ts, AAC audio only, not seekable, Android 3.0+) MPEG-4 SP • 3GPP (.3gp) VP8 • (Android 4.3+) • (Android 2.3.3+) Streamable only in Android 4.0 and above • WebM (.webm) • Matroska (.mkv, Android 4.0+) 3. a) Android supported formats
  • 35. 3. b) Media Player API RecordPlayback Audio / Video android.media.MediaPlayer android.media.MediaRecorder
  • 36. b) Playback: MediaPlayer Basics Play Media From: • Resource Folder • File System Path • URL Basically • Create new instance of MediaPlayer • Call prepare() • Call start()
  • 37. b) Playback View Playing a video File
  • 38. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <SurfaceView android:id="@+id/surfaceView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/seekBar1" android:layout_alignParentTop="true" android:layout_weight="0.67" /> </RelativeLayout> b) Layout View
  • 39. Create Using: • URI • Resource ID States: • Start • Prepare • Pause • Release • Reset • SeekTo • Stop • Error Get: • Position • Duration • isPlaying Set: Output Display Looping • Data Source • Wake Mode Listeners: • Buffering Update • Completion • Error • When Prepared Inherits from java.lang.Object b) MediaPlayer Class
  • 40. public class MainActivity extends Activity implements SurfaceHolder.Callback, OnPreparedListener, OnErrorListener, OnInfoListener { MediaPlayer mediaPlayer; SurfaceHolder surfaceHolder; SurfaceView playerSurfaceView; String videoSrc = "rtsp://v6.cache1.c.youtube.com/CjYLENy73wIaLQkDsLHya4- Z9hMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYKX4k4uBjbOiUQw=/0/0/0/video.3gp"; //String dataSrc = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"; //int resId = R.raw.sample;//.mp4 //int String dataSrc = "/sdcard/music/sample_music.mp3"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); playerSurfaceView = (SurfaceView) findViewById(R.id.playersurface); surfaceHolder = playerSurfaceView.getHolder(); surfaceHolder.addCallback(this); } b) Activity Code
  • 41. @Override public void surfaceCreated(SurfaceHolder arg0) { try { mediaPlayer = new MediaPlayer(); mediaPlayer.setDisplay(surfaceHolder); mediaPlayer.setDataSource(videoSrc); mediaPlayer.setOnPreparedListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.prepare(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } b) Activity Code
  • 42. @Override public void onPrepared(MediaPlayer mp) { mediaPlayer.start(); } @Override public boolean onError(MediaPlayer mp, int what, int extra) { Log.e("MainActivity", "what="+what+" extra="+extra); return false; } @Override public boolean onInfo(MediaPlayer mp, int what, int extra) { Log.i("MainActivity", "what="+what+" extra="+extra); return false; } b) Activity Code
  • 44. c) Limitations of Media Player • Any time media player changes state, check before selecting any action or you may fall into IllegalStateException. • Error when the orientation of screen is change, even if you manage the tag screenOrientation=“orientation” in manifest.xml • When activity goes in background and MediaPlayer is playing, even if you have handled onPause and onResume in some devices it goes to error state. • There are 30 to 34 types of possible error starting from -1 to -34. For e.g. Error: the video container is not valid for progressive playback (-32); Error due to resource being in wrong state to handle request (-14) Error due to general data processing(-18)
  • 45. c) Limitations of Media Player • public static void playMusic(int id) { // Not a good practice MediaPlayer mediaPlayer = MediaPlayer.create(context, id); mediaPlayer.setLooping(true); mediaPlayer.start(); } // Here the media player will be removed by GC even if it is in play mode. • The error value (1, -2147483648), the '1' value corresponds to the constant in MediaPlayer.MEDIA_ERROR_UNKNOWN. (This might happen) -2147483648 corresponds to hexadecimal 0x80000000 which is defined as UNKNOWN_ERROR
  • 46. 4. Advanced Media Player Development • Customization Features • Benefits of Customization • Drawbacks • FFMPEG Library
  • 47. We can Customize the Media Player and achieve : We can enhance security. a) Playing video in chunks b) Prevent video from getting stolen. c) Encrypt the InputStream with Cipher. • Real Time manipulation.(Play ads in between) • Adaptive Streaming.(Configurable bandwidth) • Multi Format Playing.(discussed later) a) Customization Features
  • 48. • Your video content is secure. • Easily applicable to other java platforms too for e.g. J2ME • Saved video can be played only by our media player. • Configurable bandwidth according to network speed. • Since playback is chunk by chunk you can show video ads in between them too. • Event handling during playback is possible for e.g. at what point the user stops the video or how much percentage watched. b) Benefits of Customization
  • 49. • Decoding of Android media player is bad, may fall into lot of errors and you might not get possible solution anywhere. (Limited number of file formats) • The total chunk playback duration and the clip playback duration should match or the player will again throw errors like ChunkNotFound (Custom exception). c) Drawbacks
  • 50. d) FFMPEG Library • Almost every android phone user is friendly with MX Player which is a pretty famous player. • MX Player is build using FFMpeg library which we will discuss later. • It is user-friendly, plays almost all formats and possesses great build-in features.
  • 51. • Plays almost every movie files including .3gp .avi .divx .f4v .flv .mkv .mp4 .mpeg .mov .vob .wmv .webm .xvid and many more • Hardware decoding (with h/w+ decoder) • Processor optimization • High speed rendering for ARM® NEON™ compliant processors. • Provides processor specific Codecs including Tegra 2 processor. • Move forward/backward (Optional) • Aspect ratio selection d)Features of MX Player
  • 52. Following conditions are required to run included shell script: •Linux or Cygwin •Latest Google NDK Download ffmpeg source code 1.In config-ffmpeg.sh, change "NDK" variable to point NDK path. 2.Add this line NDK=$HOME/Desktop/adt/android-ndk-r9 3.In build.sh, change "MAKE" variable to point ndk-build script of NDK directory. 4.Run the shell scripts by command ./build.sh 5.The build can take a while to finish depending on your computer speed. 6.Make ffmpeg Libraries available for Your Projects How to build FFmpeg for Android
  • 53. References Video Characteristics: http://en.wikipedia.org/wiki/Video Android Developer Site: http://developer.android.com/reference/android/media/MediaPlayer.html FFMPEG Build: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/