Rumah  >  Artikel  >  Java  >  Cara Membuat Aplikasi Panggilan Video dengan ZEGOCLOUD

Cara Membuat Aplikasi Panggilan Video dengan ZEGOCLOUD

DDD
DDDasal
2024-09-25 06:24:07682semak imbas

How to Make a Video Call App with ZEGOCLOUD

Möchten Sie Ihre eigene Videoanruf-App erstellen? Dank ZEGOCLOUD ist es einfacher, als Sie vielleicht denken. Diese Anleitung zeigt Ihnen Schritt für Schritt, wie Sie eine Videoanruf-App erstellen. ZEGOCLOUD bietet Tools, die den Prozess vereinfachen, selbst wenn Sie neu in der App-Entwicklung sind.

Sie erfahren, wie Sie Ihr Projekt einrichten, Videoanruffunktionen hinzufügen und dafür sorgen, dass Ihre App reibungslos läuft. Wir behandeln die Grundlagen, die Sie wissen müssen, von den ersten Schritten mit ZEGOCLOUD bis zum Testen Ihrer fertigen App. Am Ende verfügen Sie über eine funktionierende Videoanruf-App, die Sie selbst erstellt haben.

Ganz gleich, ob Sie Anfänger sind oder etwas Programmiererfahrung haben, dieser Leitfaden hilft Ihnen, schnell und einfach eine Videoanruf-App mit ZEGOCLOUD zu erstellen.

Wie lange dauert die Erstellung einer App?

Das Erstellen einer App nimmt Zeit in Anspruch und die genaue Dauer hängt von der Komplexität und den Funktionen der App ab. Die Entwicklung einfacher Apps mit Grundfunktionen kann etwa 2-3 Monate dauern. Diese Apps verfügen normalerweise über minimale Funktionen, wie zum Beispiel ein paar Bildschirme und Standardfunktionen.

Andererseits können komplexere Apps, die Funktionen wie Benutzerauthentifizierung, Datenbankintegration oder Echtzeitaktualisierungen umfassen, 4–6 Monate oder länger dauern. Diese Apps erfordern eine detailliertere Planung, Gestaltung und Tests, um sicherzustellen, dass alles reibungslos läuft.

Ein weiterer Faktor, der die Entwicklungszeit beeinflusst, ist die Größe des Teams, das an dem Projekt arbeitet. Ein größeres, erfahrenes Team kann die App schneller fertigstellen als eine kleinere Gruppe. Auch die Qualität der Kommunikation und des Projektmanagements spielt eine Rolle dabei, wie schnell die App fertiggestellt werden kann.

Es ist auch wichtig zu beachten, dass die App-Entwicklung nicht nach dem Start endet. Regelmäßige Updates und Wartung sind erforderlich, um Fehler zu beheben und den reibungslosen Betrieb der App sicherzustellen.

Insgesamt kann die Erstellung einer App je nach Umfang des Projekts zwischen einigen Monaten und über einem Jahr dauern. Eine gute Planung und ein klares Verständnis der Anforderungen der App können helfen, den Prozess zu beschleunigen.

iOS-App-Entwicklung vs. Android-App-Entwicklung: Was ist der Unterschied?

Beim Erstellen einer mobilen App können Sie zwischen iOS für Apple-Geräte oder Android für viele andere Telefone wählen. Beide sind beliebt, weisen jedoch einige wesentliche Unterschiede auf. Vergleichen wir sie:

Criteria

iOS App Development

Android App Development

Programming Language Swift and Objective-C Kotlin and Java
Development Environment Xcode Android Studio
Device Fragmentation Less device variety, easier to test Wide range of devices, harder to test
App Store Approval Strict review process Less strict, faster approval
Market Share Popular in North America and Europe Dominates in Asia, Africa, and more
Development Cost Usually higher due to stricter guidelines Can be lower, but depends on the complexity
Revenue Potential Higher app revenue per user Larger audience, but lower revenue per user

Perbezaan Utama:

  • Bahasa Pengaturcaraan: Apl iOS dibina dengan Swift atau Objective-C, manakala apl Android menggunakan Kotlin atau Java. Swift lebih baharu dan lebih mudah dipelajari, manakala Kotlin lebih serba boleh merentas peranti Android.
  • Pecahan Peranti: Pembangun iOS berurusan dengan lebih sedikit model peranti, menjadikan ujian lebih mudah. Walau bagaimanapun, pembangun Android perlu mengambil kira banyak peranti dan saiz skrin yang berbeza.
  • Potensi Hasil: Apl iOS sering menjana hasil yang lebih tinggi, terutamanya daripada pembelian dalam apl. Apl Android menjangkau khalayak yang lebih besar tetapi mungkin memperoleh lebih sedikit bagi setiap pengguna.

Secara keseluruhan, kedua-dua platform menawarkan faedah unik dan pilihan bergantung pada khalayak sasaran dan matlamat anda.

Cara Membuat Apl Panggilan Video untuk Android dan iOS

Membuat apl panggilan video untuk Android dan iOS mungkin kelihatan sukar, tetapi dengan alatan yang betul, ia lebih mudah daripada yang anda fikirkan. Dalam bahagian ini, kami akan menunjukkan kepada anda cara melakukannya menggunakan ZEGOCLOUD Express SDK.

ZEGOCLOUD ialah platform berkuasa yang memudahkan anda menambahkan ciri video dan audio masa nyata pada apl anda. Ia menjaga bahagian yang rumit, jadi anda boleh memberi tumpuan kepada memberikan pengguna anda pengalaman yang lancar. Dengan ZEGOCLOUD, membina apl panggilan video untuk Android dan iOS adalah pantas dan mudah.

Prasyarat

Sebelum kita bermula, mari pastikan anda mempunyai semua yang anda perlukan:

  • Daftar untuk akaun pembangun ZEGOCLOUD.
  • Dapatkan AppID dan AppSign anda daripada papan pemuka pentadbir ZEGOCLOUD.
  • Pasang Android Studio 2020.3.1 di atas atau Xcode 13.0 untuk apl iOS.
  • Gunakan peranti yang menjalankan Android 4.4 atau iOS 9.0 atau lebih baharu yang menyokong audio dan video.
  • Pengetahuan tentang pembangunan apl Android atau iOS.
  • Pastikan peranti anda disambungkan ke Internet.

Apl Panggilan Video Android

1. Menambah Ketergantungan SDK

1.1 Menyediakan Gradle

Untuk menggunakan Zego SDK, anda mesti menambahkan ZegoExpress SDK pada projek Android anda melalui Gradle. Ikuti langkah di bawah untuk berbuat demikian:

  • Untuk Android Studio versi 7.1.0 atau lebih baru, buka fail settings.gradle projek anda. Tambahkan kod berikut di dalam blok dependencyResolutionManagement:
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven { url 'https://storage.zego.im/maven' }
        google()
        mavenCentral()
    }
}
  • Untuk versi lama Android Studio, buka fail build.gradle dalam direktori akar projek anda. Tambahkan kod berikut di dalam blok allprojects:

    allprojects {
    repositories {
        maven { url 'https://storage.zego.im/maven' }
        google()
        mavenCentral()
    }
    }
    

1.2 Menambah Kebergantungan SDK

Buka fail app/build.gradle. Tambahkan baris berikut di dalam blok dependencies (ganti xyz dengan versi SDK terkini):

dependencies {
    implementation 'im.zego:express-video:x.y.z'
}

Simpan fail dan segerakkan projek. Ini akan menambah SDK ZegoExpress, mendayakan fungsi panggilan video.

2. Mengimport SDK

Setelah kebergantungan disegerakkan, import Zego SDK ke dalam aktiviti utama anda supaya anda boleh mula melaksanakan ciri panggilan video.

Buka fail MainActivity.java atau MainActivity.kt anda. Tambahkan pernyataan import berikut:

import im.zego.zegoexpress.ZegoExpressEngine;

Import ini membolehkan anda menggunakan fungsi teras Zego SDK.

3. Melaksanakan Fungsi Panggilan Video

3.1 Tentukan Bukti Kelayakan Apl

Anda perlu menentukan AppID dan AppSign anda, yang anda perolehi daripada papan pemuka ZEGOCLOUD anda.

Dalam fail aktiviti utama anda, tambahkan pembolehubah berikut:

String appID = "c12dbc38b67451a9ee8a0ba266840aab";  // Replace with your actual AppID
String appSign = "fe1529d55bcbcc0fa462cba668b8f2bd";  // Replace with your actual AppSign

3.2 Tentukan Maklumat Pengguna dan Bilik

Sekarang, tentukan ID pengguna, Nama pengguna dan ID bilik untuk mengenal pasti pengguna dan bilik panggilan video. Takrifkan pembolehubah:

String userID = "fc4a8a14869bc3b8f84d052a35378195";   // Replace with your actual user ID
String userName = "c157e43fc1e6147c21d7b2f420f7501f"; // Replace with your actual user name
String roomID = "93429f3717703a6e1b861e1d1565e862";   // Replace with your actual room ID

3.3 Memulakan Enjin Zego

Sebelum memulakan panggilan, anda mesti memulakan enjin Zego. Enjin ini akan mengendalikan semua operasi panggilan video. Tambah kaedah berikut untuk memulakan enjin:

void createEngine() {
    ZegoEngineProfile profile = new ZegoEngineProfile();
    profile.appID = Long.parseLong(appID);
    profile.appSign = appSign;
    profile.application = getApplication();
    profile.scenario = ZegoScenario.DEFAULT; // Set the appropriate scenario
    ZegoExpressEngine.createEngine(profile, null);
}

Kaedah ini memulakan ZegoExpressEngine dengan appID dan appSign. Senario ditetapkan kepada LALAI, yang sesuai untuk kes penggunaan umum.

3.4 Memulakan dan Menyertai Panggilan Video

Sekarang, laksanakan kaedah untuk memulakan dan menyertai panggilan video.

Memulakan Panggilan Video:

void startVideoCall() {
    ZegoExpressEngine.getEngine().startPublishingStream(roomID);
}

Menyertai Panggilan Video:

void joinVideoCall() {
    ZegoExpressEngine.getEngine().startPlayingStream(roomID);
}

4. Mengkonfigurasi Kebenaran Peranti

Untuk panggilan video mengakses kamera dan mikrofon anda, anda perlu meminta kebenaran dalam fail AndroidManifest.xml. Buka fail AndroidManifest.xml dan tambahkan kebenaran berikut:

eafa53ed60cf631bb40427ba7fd27cc3
cc4be989b182b85ab53d6e27e2649273
80768a34d765d25f66049afad58fea64

Untuk Android 6.0 dan ke atas, anda juga perlu meminta kebenaran masa jalan:

String[] permissions = {"android.permission.CAMERA", "android.permission.RECORD_AUDIO"};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    requestPermissions(permissions, 101);
}

5. Menjalankan dan Menguji Apl Android Anda

Setelah anda menetapkan kebenaran, anda kini boleh menjalankan dan menguji apl Android anda:

  • Build and run your app on a real Android device.
  • Test the video call by starting the call on one device and joining the call on another using the same roomID.

iOS Video Call App

1. Adding the SDK Dependencies

1.1 Setting Up Swift Package Manager

For iOS, you will use Swift Package Manager to add the ZegoUIKitPrebuiltLiveStreaming SDK. Follow the steps below:

  • Open Xcode, and go to File > Add Packages.
  • In the search box, enter the following URL:
https://github.com/zegolibrary/express-video-ios

Select the latest version and add the package to your project.

2. Importing the SDK

Once the SDK is installed, you need to import it into your ViewController.swift file. In your ViewController.swift file, add the following import statements:

import ZegoUIKit
import ZegoUIKitPrebuiltLiveStreaming

These import statements give you access to the Zego video call SDK.

3. Implementing Video Call Functionality

3.1 Define App Credentials

You need your AppID and AppSign to authenticate your app with ZEGOCLOUD. Add the following credentials at the top of your ViewController.swift file:

let appID: UInt32 = 0122b644d0a0273642508c49a6bb2b8e  // Replace with your actual AppID
let appSign: String = "86c79318892e84f5d80aa6d0c14c7516"  // Replace with your actual AppSign

3.2 Define User and Room Information

Now, define the userID, userName, and roomID variables for identifying users and the room. Add these variables:

var userID: String = "fc4a8a14869bc3b8f84d052a35378195"   // Replace with actual user ID
var userName: String = "c157e43fc1e6147c21d7b2f420f7501f" // Replace with actual user name
var roomID: String = "93429f3717703a6e1b861e1d1565e862"   // Replace with actual room ID

3.3 Initializing the Zego Engine

Like Android, you must initialize the Zego engine on iOS to handle video call functionality. Add the function below:

func createEngine() {
    let profile = ZegoEngineProfile()
    profile.appID = appID
    profile.appSign = appSign
    ZegoExpressEngine.createEngine(with: profile, eventHandler: self)
}

This function initializes the Zego engine with your credentials.

3.4 Starting and Joining a Video Call

To start a video call as a host:

func startVideoCall() {
    ZegoExpressEngine.shared().startPublishingStream(roomID)
}

To join an existing video call:

func joinVideoCall() {
    ZegoExpressEngine.shared().startPlayingStream(roomID)
}

4. Configuring Device Permissions

In iOS, you need to request camera and microphone permissions in the Info.plist file. Open the Info.plist file and add the following keys:

42538adbdb6240b2b083a000a615d5bdNSCameraUsageDescription9780a7140ed8471d130dc57bcb9b0bd2
98c455a79ddfebb79781bff588e7b37eWe need access to your camera for video calls.dba3c644993c36696c11b074e67a4078
42538adbdb6240b2b083a000a615d5bdNSMicrophoneUsageDescription9780a7140ed8471d130dc57bcb9b0bd2
98c455a79ddfebb79781bff588e7b37eWe need access to your microphone for video calls.dba3c644993c36696c11b074e67a4078

These entries will display permission prompts when the user first opens the app.

5. Running and Testing Your Video Call App

Once your permissions are set, you can now test your app:

  • Open the .xcworkspace file in Xcode, select your target device, and run the app.
  • Start a video call on one device, then join it from another device using the same room ID to test the feature.

These are just the basics. To add more features to your video call app, explore ZEGOCLOUD’s Express Video SDK documentation. You can also get started with our sample source code!

Conclusion

Building a video call app with ZEGOCLOUD is a straightforward process, whether you're developing for Android or iOS. By following this guide, you can set up your project, integrate essential video calling features, and test the app on real devices. ZEGOCLOUD’s powerful SDK simplifies the implementation, allowing you to focus on user experience rather than complex backend processes.

Start building your custom video call app today and create seamless communication experiences for your users.

Atas ialah kandungan terperinci Cara Membuat Aplikasi Panggilan Video dengan ZEGOCLOUD. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn