Mobile Development 11 min read

Cross‑Platform Audio Player Framework for Smart Scenic Spot Guides

The Gaode Smart Scenic Spot Pocket‑Player framework provides a cross‑platform, hybrid audio solution that delivers location‑based MP3 guides, isolates business logic via an observer‑based service, manages audio focus and interruptions efficiently, supports cross‑page and offline playback, and enables rapid, low‑resource development for immersive tourist experiences.

Amap Tech
Amap Tech
Amap Tech
Cross‑Platform Audio Player Framework for Smart Scenic Spot Guides

1. Background

Audio guides are a key service in smart scenic spots. The goal is to let users walk while listening to location‑based voice introductions via the map, turning a visual map into an auditory experience and dramatically improving user interaction.

We aim to give technology “temperature”, making explanations more emotional and meaningful, and to build a UGC‑driven scenic‑guide ecosystem where creators can earn revenue, creating a positive feedback loop for online tour guides.

Imagine a visitor at the Forbidden City hearing a voice‑over that says, “The Palace holds 1.8 million treasures, including the Bronze Hall and the Ceramics Hall,” narrated by a famous collector. Or at the Yanxi Palace, the guide links the site to the popular TV drama “Yanxi Palace” with background music, making the experience vivid.

Therefore, instead of traditional TTS, we use generic audio formats (e.g., MP3) as the source, allowing creators to remix the content. This article briefly reviews the design and implementation of the Gaode Smart Scenic Spot “Pocket‑Player” framework.

2. Pre‑Architecture Considerations

Before the battle, we must “plan in the temple” to keep technical risks controllable – a principle of “preventing fire rather than fighting it”.

How to improve development and iteration efficiency? The choice is between pure native development and cross‑platform hybrid development. Native yields mature audio solutions but doubles effort for iOS and Android. A cross‑platform approach, although technically challenging (e.g., bridging JS playback chains and handling audio‑interrupt callbacks), offers “Write Once, Run Everywhere”, aligning codebases, shortening development cycles, and supporting rapid feature iteration.

How to save CPU, memory, and battery resources? Audio playback is resource‑intensive on mobile devices and must coexist with other apps (phone calls, music players) that may compete for audio focus.

Consequently, the business layer must wrap the underlying player, control instance creation, and manage audio‑focus acquisition and release across third‑party apps.

How to isolate business logic from the audio playback framework? Audio capabilities (play, pause, resume, volume control, handling interruptions, caching, pre‑loading, network variations, error recovery) should be decoupled from business code, adhering to high cohesion and low coupling.

We adopted the Observer pattern: business modules register listeners to the audio framework, which handles focus stealing, recovery, and event dispatching, following the Single‑Responsibility Principle.

How to achieve cross‑page playback?

Directly exposing playback to each page would create many audio instances and high communication overhead. Instead, we introduced a BizService (similar to Android Service) that hosts a BizVoiceMediaCenter, which interacts with a single VoiceMediaAlbum instance (providing playlist, next/previous, sequential play, resume, etc.).

3. Architecture Design and Development

The lifecycle of the cross‑platform underlying player mirrors Android’s system player, with differences in audio‑focus callbacks: iOS uses onInterrupted / onInterruptedEnd , while Android uses onFocusChanged . Additional differences (error codes, timeout handling) are unified in a custom VoiceMediaPlayer.

Business code wraps the low‑level Audio into VoiceMediaPlayer, which then uses VoiceMediaAlbum (playlist management) and BizVoiceMediaCenter (business‑level API). This separation keeps the audio engine stable while allowing flexible business extensions.

4. Deliverables and Outcomes

The completed Gaode Smart Scenic Spot Pocket‑Player framework has supported multiple product iterations with minimal architectural changes, even after adding offline playback. The framework proved stable, extensible, and capable of handling cross‑page audio management, focus interruptions, and error recovery, providing a solid foundation for future audio‑related features.

Note

Gaode Map, together with Alibaba Cloud Tianchi, is sponsoring the AMAP‑TECH algorithm competition (vehicle video‑based dynamic traffic analysis). Participants are invited to join the contest for prizes and recognition.

design patternsMobilecross‑platformarchitectureresource optimizationAudio
Amap Tech
Written by

Amap Tech

Official Amap technology account showcasing all of Amap's technical innovations.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.