Avoid using deprecated APIs during development.
// code-linter.json5
{
"rules": {
"@compatibility/deprecate-api-check": "suggestion"
}
} import media from '@ohos.multimedia.media';
function nonDeprecatedApi(): void {
media.createAVPlayer().then((avPlayer) => {
avPlayer.on('stateChange', () => {});
avPlayer.play();
});
} import { media } from '@kit.MediaKit';
function deprecatedApi(): void {
let audioPlayer: media.AudioPlayer = media.createAudioPlayer ();
audioPlayer.src = 'https://example.com/audio.mp3';
audioPlayer.play ();
audioPlayer.release ();
} plugin:@compatibility/all
For details about how to configure Code Linter check rules, see Code Linter.