apache / apache/cordova-plugin-media

Cannot read property 'pause' of null

Open
#270 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
391
Forks
762
PR merge metrics
No merged PRs in 30d

Description

### Issue Type

- [x] Bug Report
- [ ] Feature Request
- [x ] Support Question

## Description
When i try to pause and stop a audio i am getting an error saying "Cannot read property 'pause' of null". I can perfectly play the audio.
## Information
I am using phonegap and i am including the script at end of page before body.

### Command or Code
var my_media = null;
var mediaTimer = null;

function playAudio(src) {
var url = src;
var my_media = new Media(url,
// success callback
function () {
console.log("playAudio():Audio Success");
media.release();
},
// error callback
function (err) { console.log("playAudio():Audio Error: " + err);
alert("Download the audio first!")
}
);
// Play audio
my_media.play();
}

// Pause audio
//
function pauseAudio() {
my_media.pause();


}

// Stop audio
//
function stopAudio() {
my_media.stop();
clearInterval(mediaTimer);
mediaTimer = null;
}

// onSuccess Callback
//
function onSuccess() {
console.log("playAudio():Audio Success");
}

// onError Callback
//
function onError(error) {
console.log('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}

### Environment, Platform, Device
In phonegap, Android, Any device

### Version information

## Checklist

- [x ] I searched for already existing GitHub issues about this
- [x ] I updated all Cordova tooling to their most recent version
- [x ] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Start with the supplied playAudio(), pauseAudio(), and stopAudio() entry points and verify the reported behavior on an Android device. Confirm whether the null value is reproducible in the media plugin rather than only in the calling application; done means a reproducible plugin defect with a narrowed location, or a clear support resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.