Android的MediaPlayer错误[转载]
2011年09月01日
重要提醒:系统检测到您的帐号可能存在被盗风险,请尽快查看风险提示,并立即修改密码。 | 关闭
网易博客安全提醒:系统检测到您当前密码的安全性较低,为了您的账号安全,建议您适时修改密码 立即修改 | 关闭
在使用MediaPlayer的时候,要注意几个Listener的配合使用,但是,MediaPlayer还是会经常报些奇怪的错误信息。
通常这些错误都是由数据源或者调用MediaPlayer中的方法时没有注意MediaPlayer的状态而引起。
常见错误信息分析:
(-38,0)
一般是由于在MediaPlayer还没有Prepared的状态下调用了类似getDuration()之类的方法而引起,
例如报错:Attempt to call getDuration without a valid mediaplayer
以下是MediaPlayer的错误类型源码: /* -------------------------------------------------- ----------------
* Copyright (C) 1998-2010 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------- -----------------
*/
/**
* @file pv_return_codes.h
* @brief This file defines the general return and event codes to be used by PVMF elements.
* Theses base-level codes are unique. Error codes are negative values and informational
* codes are positive values.
* NOTE: If you add any new event, update the PVMFStatusToString method as well.
*/
// Return codes
/*
Return code for general success
*/
const PVMFStatus PVMFSuccess = 1;
/*
Return code for pending completion
*/
const PVMFStatus PVMFPending = 0;
/*
Return code for never set
*/
const PVMFStatus PVMFNotSet = 2;
/*
Return code for Command Complete
*/
const PVMFStatus PVMFCmdCompleted = 3;
/*
Definition of first error event in range (not an actual error code).
*/
const PVMFStatus PVMFErrFirst = (-1);
/*
Return code for general failure
*/
const PVMFStatus PVMFFailure = (-1);
/*
Error due to cancellation
*/
const PVMFStatus PVMFErrCancelled = (-2);
/*
Error due to no memory being available
*/
const PVMFStatus PVMFErrNoMemory = (-3);
/*
Error due to request not being supported
*/
const PVMFStatus PVMFErrNotSupported = (-4);
/*
Error due to invalid argument
*/
const PVMFStatus PVMFErrArgument = (-5);
/*
Error due to invalid resource handle being specified
*/
const PVMFStatus PVMFErrBadHandle = (-6);
/*
Error due to resource already exists and another one cannot be created
*/
const PVMFStatus PVMFErrAlreadyExists = (-7);
/*
Error due to resource being busy and request cannot be handled
*/
const PVMFStatus PVMFErrBusy = (-8);
/*
Error due to resource not ready to accept request
*/
const PVMFStatus PVMFErrNotReady = (-9);
/*
Error due to data corruption being detected
*/
const PVMFStatus PVMFErrCorrupt = (-10);
/*
Error due to request timing out
*/
const PVMFStatus PVMFErrTimeout = (-11);
/*
Error due to general overflow
*/
const PVMFStatus PVMFErrOverflow = (-12);
/*
Error due to general underflow
*/
const PVMFStatus PVMFErrUnderflow = (-13);
/*
Error due to resource being in wrong state to handle request
*/
const PVMFStatus PVMFErrInvalidState = (-14);
/*
Error due to resource not being available
*/
const PVMFStatus PVMFErrNoResources = (-15);
/*
Error due to invalid configuration of resource
*/
const PVMFStatus PVMFErrResourceConfiguration = (-16);
/*
Error due to general error in underlying resource
*/
const PVMFStatus PVMFErrResource = (-17);
/*
Error due to general data processing
*/
const PVMFStatus PVMFErrProcessing = (-18);
/*
Error due to general port processing
*/
const PVMFStatus PVMFErrPortProcessing = (-19);
/*
Error due to lack of authorization to access a resource.
*/
const PVMFStatus PVMFErrAccessDenied = (-20);
/*
Unused error code. Can be re-defined.
*/
const PVMFStatus PVMFErrUnused_01 = (-21);
/*
Unused error code. Can be re-defined.
*/
const PVMFStatus PVMFErrUnused_02 = (-22);
/*
Error due to the download content length larger than the maximum request size
*/
const PVMFStatus PVMFErrContentTooLarge = (-23);
/*
Error due to a maximum number of objects in use
*/
const PVMFStatus PVMFErrMaxReached = (-24);
/*
Return code for low disk space
*/
const PVMFStatus PVMFLowDiskSpace = (-25);
/*
Error due to the requirement of user-id and password input from app for HTTP basic/digest authentication
*/
const PVMFStatus PVMFErrHTTPAuthenticationRequired = (-26);
/*
PVMFMediaClock specific error. Callback has become invalid due to change in direction of NPT clock.
*/
const PVMFStatus PVMFErrCallbackHasBecomeInvalid = (-27);
/*
PVMFMediaClock specific error. Callback is called as clock has stopped.
*/
const PVMFStatus PVMFErrCallbackClockStopped = (-28);
/*
Error due to missing call for ReleaseMatadataValue() API
*/
const PVMFStatus PVMFErrReleaseMetadataValueNotDone = (-29);
/*
Error due to the redirect error
*/
const PVMFStatus PVMFErrRedirect = (-30);
/*
Error if a given method or API is not implemented. This is NOT the same as PVMFErrNotSupported.
*/
const PVMFStatus PVMFErrNotImplemented = (-31);
/*
DRM license not found
*/
const PVMFStatus PVMFErrDrmLicenseNotFound = (-32);
/*
DRM license has expired due to end time or usage count restriction
*/
const PVMFStatus PVMFErrDrmLicenseExpired = (-33);
/*
DRM license has a start time restriction and current time is too early
*/
const PVMFStatus PVMFErrDrmLicenseNotYetValid = (-34);
/*
DRM rights are insufficient for the requested operation
*/
const PVMFStatus PVMFErrDrmInsufficientRights = (-35);
/*
DRM rights require higher output protection level than supported by the device
*/
const PVMFStatus PVMFErrDrmOutputProtectionLevel = (-36);
/*
DRM clock rollback detected.
*/
const PVMFStatus PVMFErrDrmClockRollback = (-37);
/*
DRM clock is not available or cannot be read
*/
const PVMFStatus PVMFErrDrmClockError = (-38);
/*
DRM license store is corrupted
*/
const PVMFStatus PVMFErrDrmLicenseStoreCorrupt = (-39);
/*
DRM license store is not valid for the device.
*/
const PVMFStatus PVMFErrDrmLicenseStoreInvalid = (-40);
/*
DRM license store access failed
*/
const PVMFStatus PVMFErrDrmLicenseStoreAccess = (-41);
/*
DRM Device data access failed
*/
const PVMFStatus PVMFErrDrmDeviceDataAccess = (-42);
/*
DRM network error occurred in server communication
*/
const PVMFStatus PVMFErrDrmNetworkError = (-43);
/*
DRM device ID cannot be determined
*/
const PVMFStatus PVMFErrDrmDeviceIDUnavailable = (-44);
/*
DRM data is not matched to device
*/
const PVMFStatus PVMFErrDrmDeviceDataMismatch = (-45);
/*
DRM cryptography operation failed
*/
const PVMFStatus PVMFErrDrmCryptoError = (-46);
/*
DRM license not found, but a preview of the content is available.
*/
const PVMFStatus PVMFErrDrmLicenseNotFoundPreviewAvailable = (-47);
/*
Error due to unable to communicate with server
*/
const PVMFStatus PVMFErrDrmServerError = (-48);
/*
Error when a license server requests registration to a domain.
*/