Code example for AssetFileDescriptor

Methods: close, getFileDescriptor, getLength, getStartOffset

0
				sPlayer.setDataSource(path);
			else { 
				Context context = Director.getInstance().getContext();
				AssetManager am = context.getAssets();
				afd = am.openFd(path);
				sPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
			} 
			sPlayer.prepareAsync();
			sBgPath = path;
		} catch (Exception e) {
			Log.w("libwiengine", "Failed to preload background music: " + path);
		} finally { 
			try { 
				if(afd != null)
					afd.close();
			} catch (IOException e) {
			} 
		} 
	} 
	 
	synchronized static void mpPlayBackgroundMusic(int resId, int format, int repeatCount) {