Media player path is null
To manage DRM-controlled media, you need to include the new methods alongside the usual flow of MediaPlayer calls, as shown below:. Start by initializing the MediaPlayer object and setting its source using setDataSource , as usual. Then, to use DRM, perform these steps:. If MediaPlayer. DrmInfo exists:. By default, prepareDrm runs synchronously, blocking until preparation is finished. However, the very first DRM preparation on a new device may also require provisioning, which is handled internally by prepareDrm , and may take some time to finish due to the network operation involved.
You can avoid blocking on prepareDrm by defining and setting a MediaPlayer. When you set an OnDrmPreparedListener , prepareDrm performs the provisioning if needed and preparation in the background. When provisioning and preparation have finished, the listener is called. You should not make any assumption about the calling sequence or the thread in which the listener runs unless the listener is registered with a handler thread.
The listener can be called before or after prepareDrm returns. OnDrmPreparedListener to start the player. They work in conjunction with prepareAsync , as shown below:. Another feature that may be useful in a media player application is the ability to retrieve music that the user has on the device.
You can do that by querying the ContentResolver for external media:. To use this with the MediaPlayer , you can do this:. Content and code samples on this page are subject to the licenses described in the Content License. App Basics. Build your first app. App resources. Resource types. App manifest file.
Device compatibility. Multiple APK support. Tablets, large screens, and foldables. Build responsive UIs. Build for foldables. Getting started. Handling data. User input. Watch Face Studio. Health services. Creating watch faces. Android TV. Build TV Apps. Build TV playback apps. Help users find content on TV. Recommend TV content. Watch Next. Build TV games.
Build TV input services. TV Accessibility. Android for Cars. Build media apps for cars. Build navigation, parking, and charging apps for cars. Chrome OS devices. App architecture. Guide to app architecture. UI layer. Architecture Components. UI layer libraries. View binding. Data binding library. Lifecycle-aware components. Paging Library. Paging 2. Data layer libraries. How-To Guides. Advanced Concepts. Threading in WorkManager. App entry points.
App shortcuts. App navigation. Navigation component. App links. Dependency injection. Core topics. App compatibility. Interact with other apps. Package visibility. Intents and intent filters. User interface. Add motion to your layout with MotionLayout. MotionLayout XML reference. Improving layout performance. Custom view components. Look and feel. Splash screens. Add the app bar. Window insets. Supporting swipe-to-refresh. Pop-up messages overview.
Adding search functionality. Creating backward-compatible UIs. Home channels for mobile apps. App widgets. Media app architecture. Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
Skip to content. Star New issue. Jump to bottom. Copy link. Version of react-native-audio-recorder-player 2. Android Expected behaviour To record and play sound just like in ios iOS runs successfully without any warnings Actual behaviour Sound is being recorded, because the recordBackListener is updating the state and showing the seconds.
After the recording is done, I try to play the sound and the state of playBackListener updates correctly and plays until the end of sound-clip, but the following error comes: Possible Unhandled Promise Rejection id: 0 : Error: mediaPlayer is null. Won't grant permission to the first level of dir. I appreciate your help in telling me what is wrong in my code that makes MediaPlayer does not work with URI.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 5 years, 2 months ago. Active 5 years, 2 months ago. Viewed times. NullPointerException Improve this question. Add a comment.
0コメント