Maison  >  Article  >  Java  >  Comment créer une application d'appel vidéo avec ZEGOCLOUD

Comment créer une application d'appel vidéo avec ZEGOCLOUD

DDD
DDDoriginal
2024-09-25 06:24:07686parcourir

How to Make a Video Call App with ZEGOCLOUD

Vous souhaitez créer votre propre application d'appel vidéo ? C'est plus facile que vous ne le pensez, grâce à ZEGOCLOUD. Ce guide vous montrera comment créer une application d'appel vidéo étape par étape. ZEGOCLOUD propose des outils qui simplifient le processus, même si vous débutez dans le développement d'applications.

Vous apprendrez à configurer votre projet, à ajouter des fonctionnalités d'appel vidéo et à faire fonctionner votre application sans problème. Nous couvrirons les bases que vous devez connaître, depuis la prise en main de ZEGOCLOUD jusqu'au test de votre application terminée. À la fin, vous disposerez d’une application d’appel vidéo fonctionnelle que vous avez créée vous-même.

Que vous soyez débutant ou que vous ayez une certaine expérience en codage, ce guide vous aidera à créer une application d'appel vidéo rapidement et facilement avec ZEGOCLOUD.

Combien de temps faut-il pour créer une application ?

Créer une application prend du temps, et la durée exacte dépend de la complexité et des fonctionnalités de l'application. Le développement d’applications simples dotées de fonctions de base peut prendre environ 2 à 3 mois. Ces applications ont généralement des fonctionnalités minimales, telles que quelques écrans et des fonctionnalités standard.

D'un autre côté, les applications plus complexes qui incluent des fonctionnalités telles que l'authentification des utilisateurs, l'intégration de bases de données ou les mises à jour en temps réel peuvent prendre 4 à 6 mois ou plus. Ces applications nécessitent une planification, une conception et des tests plus détaillés pour garantir que tout fonctionne correctement.

Un autre facteur qui influence le temps de développement est la taille de l'équipe travaillant sur le projet. Une équipe plus nombreuse et expérimentée peut terminer l'application plus rapidement qu'un groupe plus petit. La qualité de la communication et de la gestion du projet joue également un rôle dans la rapidité avec laquelle l'application peut être réalisée.

Il est également important de noter que le développement d’applications ne s’arrête pas après le lancement. Des mises à jour et une maintenance régulières sont nécessaires pour corriger les bugs et assurer le bon fonctionnement de l'application.

Dans l'ensemble, la création d'une application peut prendre de quelques mois à plus d'un an, selon la portée du projet. Une bonne planification et une compréhension claire des exigences de l'application peuvent aider à accélérer le processus.

Développement d'applications iOS et développement d'applications Android : quelle est la différence ?

Lorsque vous créez une application mobile, vous pouvez choisir entre iOS pour les appareils Apple ou Android pour de nombreux autres téléphones. Les deux sont populaires, mais ils présentent quelques différences clés. Comparons-les :

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.

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn