0% found this document useful (0 votes)
5 views4 pages

Android Media Recorder App in Kotlin

The document outlines an assignment on mobile app development by Abdullah Hashmi, focusing on creating a media recorder application using Kotlin in Android Studio. It includes a basic code structure for recording video with audio, highlighting the setup of buttons for starting and stopping the recording process. Additionally, it emphasizes the need for necessary permissions in the AndroidManifest.xml file for microphone and camera access.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Android Media Recorder App in Kotlin

The document outlines an assignment on mobile app development by Abdullah Hashmi, focusing on creating a media recorder application using Kotlin in Android Studio. It includes a basic code structure for recording video with audio, highlighting the setup of buttons for starting and stopping the recording process. Additionally, it emphasizes the need for necessary permissions in the AndroidManifest.xml file for microphone and camera access.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Mobile App Development

Name: Abdullah Hashmi

Roll Number: BSSE-E2-20-30

Submitted to: Sir M. Yousuf

Assignment No:03
Media Recorder:

Make a new activity with help of android studio name of file is media class use
Kotin Language in itb and design with help of xml page add 2 button with start and
stop recording phase. Here is a basic Android Application code in Kotlin using
Media Recorder to record video with microphone and camera.

Main activity code of recorder media application with access of microphone


and camera.

import [Link]. MediaRecorder

import [Link]

Import [Link]

[Link] import [Link]

import [Link] class MainActivity: AppCompatActivity()

{ private var mediaRecorder:MediaRecorder?=null private var isRecording-false


onCreate(savedinstanceState: Bundle?){

override fn [Link](savedInstanceState)

setContentView([Link].activity_main)

val startButton= findViewById<Button>

([Link].start_buutton) val

stopButton= findViewById<Button>([Link].stop_button)

[Link]{
if(!IsRecording){

stopRecording()

privatefun startRecording(){

media Recorder=MediaRecorder().apply{

setAudioSource(MediaRecorder. [Link])

setVideoSource(MediaRecorder. [Link])

setOutputFormat([Link].MPEG_4)

setAudioEncoder([Link])

set Video Recoder(MediaRecorder. VideoEncoder.H264)

setOutputFile(File(getExternalFilesDir(null), "recorded_

video.mp4").absolutePath)

prepare()

start()

IsRecordeing-true

[Link](this, "Recoding started", Toast.Length_Short).show()


}

private fun stopRecording(){ mediaRecorder?.apply{

stop()

release()

media Recorder=null

isRecording-false

[Link](this, "Recording

stopped", Toast.(Length_Short).show()

Note: This code requires necessary permission of the microphone and a camera.
Add the following to your [Link] file

You might also like