Skip to main content

Android Multimedia

Android Multimedia 

  • Introduction to android multimedia in Hindi 
  • Playing audio with android multimedia in Hindi 
  • Playing video with android multimedia in Hindi 
  • Taking pictures with android in Hindi 

Introduction to Android Multimedia 

आज का एक cell phone सिर्फ बात करने के लिए ही नहीं बल्कि multimedia के लिए भी use किया जाता है। कोई भी ऐसे cell phones  use नहीं करना चाहता जिनमें multimedia support नहीं है। User phone के द्वारा music भी सुनना चाहता है, video भी देखना चाहता है और web surfing भी करना चाहता है। इन सबके लिए आपके cell phone में multimedia support होना बहुत जरुरी है। Android में आपको multimedia system खुद implement करने की आवश्यकता नहीं है। Android में google के द्वारा default multimedia system provide किया गया है जिसे आप use  कर सकते है।

What is Stage Fright?

  • Stage fright एक multimedia system है जो google के द्वारा android devices के लिए provide किया गया है। इससे पहले OpenCORE system use  किया जाता था। Stage fright को android 2.3 के साथ introduce किया गया था। Stage fright ने OpenCORE system को completely replace कर दिया है। लेकिन आप अब भी ऐसी applications बना सकते है जो दोनों systems के साथ work कर सकती है। Stage fright system की कुछ characteristics नीचे दी जा रही है।
  • Stage fright के साथ आप हर तरह के  media को playback, download और live stream में देखा जा सकता है। 
  • Stage fright बहुत से RTSP और HTTP आदि protocols को support करता है। 
  • इस system के द्वारा आप हर तरह के media को record कर सकते है। 
  • Stage fright video call भी support करता है। 
  • ये system दूसरे hardware और input output devices को support करता है। 


Playing Audio in Android 

सभी लोग music सुनना पसंद करते है। सबसे पहला जो multimedia support लोग अपने mobile में चाहते है वो ये है की उनका cell phone music play कर सके। इसके लिए android आपको built in media player provide करता है। इसको यूज़ करना बहुत ही आसान है। Android के media player को यूज़ करते हुए कोई music play करने के लिए आप 3 simple steps follow कर सकते है। 
  • सबसे पहले आप जो MP3 file play करना चाहते है उसे res/raw file में store कीजिये। 
  • इसके बाद आप MediaPlayer class का object create करेंगे और  MP3 file का reference pass करेंगे। ऐसा करने के लिए आप MediaPlayer.create() method कॉल करेंगे और उसमे current activity का context और MP3 file का URL pass करेंगे।      
  • इसके बाद आप इस object पर start() method call करेंगे।    
     

    MediaPlayer mp = new MediaPlayer();
    MediaPlayer mp1;
    mp1= mp.create(Context context, mp3 file id);
    mp1.start();




    Playing Video in Android 

    Android में आप video भी play कर सकते है। Android में video play करना audio के comparison में थोड़ा कठिन है। Video को play होने के लिए आपको view surface provide करनी पड़ती है। Android में VideoView widget होता है जो की इस task को handle करता है। इसे किसी भी layout manager के साथ इस्तेमाल किया जा सकता है। आप इसकी size और color भी change कर सकते है। VideoView को AndroidManifest.xml में define किया जाता है। इसके लिए आप <VideoView> element use करते है। इस element के 3 main attributes होते है जिन्हे आप use कर सकते है।
    • android:id - ये video की resource id होती है। 
    • android:layout_width - इस से आप view की width set करते है। 
    • android:layout_height - इस से view की height set की जाती है। 
    VideoView को आप कैसे define करेंगे इसका उदाहरण नीचे दिया जा रहा है। 


    <VideoView android:id="resource-id-of-video"
    android:layout_width="200px"
    android:layout_height="200" />


    VideoView define करने के बाद सबसे पहले आप activity class में एक window create करते है। इसके बाद VideoView का object create किया जाता है और उसे id से identify किया जाता है। इसके बाद आप एक URL string variable create  करते है जिसमे video का URL pass किया जाता है। इसके बाद आप इस URI को setVideoUri() method के द्वारा set करते है। इसके बाद आप VideoView object पर requestFocus() method call करते है। इसके बाद VideoView object पर start() method call() किया जाता है। इसका उदाहरण नीचे दिया जा रहा है।


    getWindow().setFormat(PixelFormat, UNKNOWN);

    VideoView vv = (VideoView) findViewById(R.id.videoview);

    String videopath = "path of video";

    Uri myUri = Uri.parse(videopath);

    vv.setVideoUri(myUri);
    vv.requestFocus();
    vv.start();

     

    Taking Pictures with Android 

    Android से picture लेने के लिए सबसे पहले आप AndroidManifest.xml file में camera permission लेते है।


    <uses-permission android:name="android.permission.Camera">

       
    Picture लेने के लिए आपको एक intent create करना होगा। ऐसा आप इस तरह कर सकते है।


    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);


    File को save करने के लिए आप पहले एक variable create करेंगे।


    filepath = getOutputMediaFileUri(MEDIA_TYPE_IMAGE)


    इसके बाद आप cameraIntent पर putExtra() method call करेंगे और उसमे filePath pass करेंगे।


    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, filepath);

    Comments

    Popular posts from this blog

    Android Services

    Android Services Introduction to  android services in Hindi  Declaring  services in Hindi Creating a  android service in Hindi Introduction to Android Services इससे पहले की आप जाने की service क्या होती है आइये जानते है की service क्या नहीं होती है - एक service separate प्रोसेस नहीं होती है। ये आपकी एप्लीकेशन का ही पार्ट होती है।  एक service thread नहीं होती है।  आइये अब देखते है service क्या होती है - Service एक facility होती है जिससे आप android system को बता सकते है की आप कोई काम background में करते रहना चाहते है।  Service एक facility होती है जिससे एक एप्लीकेशन अपनी कुछ functionality दूसरी applications को expose कर सकती है।    हर service क्लास का <service> declaration AndroidManifest.xml file में होना चाहिए। Services को आप context.startService() और context.bindService() मेथड्स से स्टार्ट कर सकते है।            जब service component क्रिएट होता है तो android syst...

    Android Activity

    Android Activity Activity life cycle in Hindi Starting an  android activity in Hindi Creating a new activity in Hindi Destroying an  android activity in Hindi Introduction to Activity आप की application में एक से ज्यादा activity हो सकती है। जब आप इन activities के through navigate करते है, यानि एक activity से दूसरी activity में जाते है तो activity अपनी life cycle की different stages में जाती है। उदाहरण के लिए जब आपकी activity start होती है तो ये foreground में होती है और user का पूरा focus इस पर होता है। इस process के दौरान  android  system कुछ life cycle methods को call करता है। यदि user कोई दूसरी activity start करता है तो android system उस activity के life cycle methods को call करता है और आपकी पहले वाली activity background में चली जाती है। life cycle methods में आप decide कर सकते है की जब user जाता है या वापस आता है तो आपकी activity कैसे behave करेगी।  उदाहरण के लिए यदि आप एक वीडियो player बना रहे है तो जब user किसी दूसरी activity पर जाये तो...

    Android Spinners

    Android Spinners  Introduction to  android spinners in Hindi Defining  android spinners in Hindi Creating spinner items array in Hindi Responding to spinner selections in Hindi    Introduction to Android Spinners Android spinners आपकी एप्लीकेशन में एक drop down menu होती है। इस drop down menu में बहुत से items होते है जिन्हे user choices कहते है। जब user spinner पर क्लिक करता है तो ये items शो होते है। यूज़र अपने लिए appropriate choice choose करता है। By default spinner में सबसे top वाला element शो होता है। Spinners को XML layout file में क्रिएट किया जाता है। और items की लिस्ट string resource file में क्रिएट की जाती है। जिसमे आप एक string array क्रिएट करते है।  Spinner और items को जोड़ने के लिए एक array adapter क्रिएट किया जाता है। इसके बाद selection events को respond करने के लिए OnItemSelectedListener interface को  इम्प्लीमेंट किया जाता है।  Defining Android Spinners Android spinners को आप XML l...