MediaPlayer.java ने डेटाटार्स() हस्ताक्षर सेट किए हैं जो स्ट्रिंग (पथ) और एक एफडी दोनों को स्वीकार करते हैं। वे अंततः देशी सी कोड में जाते हैं। हालांकि इनमें से एक थोड़ा अधिक कुशल हो सकता है, यह तब तक नगण्य होगा जब तक कि आप एक बार एक बार से अधिक बार अपने डेटा स्रोत को सेट नहीं कर रहे हों।
/**
* Sets the data source (file-path or http/rtsp URL) to use. Call this after
* reset(), or before any other method (including setDataSource()) that might
* throw IllegalStateException in this class.
*
* @param path the path of the file, or the http/rtsp URL of the stream you want to play
* @throws IllegalStateException if it is called
* in an order other than the one specified above
*/
public native void setDataSource(String path) throws IOException, IllegalArgumentException, IllegalStateException;
/**
* Sets the data source (FileDescriptor) to use. It is the caller's responsibility
* to close the file descriptor. It is safe to do so as soon as this call returns.
* Call this after reset(), or before any other method (including setDataSource())
* that might throw IllegalStateException in this class.
*
* @param fd the FileDescriptor for the file you want to play
* @throws IllegalStateException if it is called
* in an order other than the one specified above
*/
public void setDataSource(FileDescriptor fd)
throws IOException, IllegalArgumentException, IllegalStateException {
// intentionally less than LONG_MAX
setDataSource(fd, 0, 0x7ffffffffffffffL);
}
/**
* Sets the data source (FileDescriptor) to use. It is the caller's responsibility
* to close the file descriptor. It is safe to do so as soon as this call returns.
* Call this after reset(), or before any other method (including setDataSource())
* that might throw IllegalStateException in this class.
*
* @param fd the FileDescriptor for the file you want to play
* @param offset the offset into the file where the data to be played starts, in bytes
* @param length the length in bytes of the data to be played
* @throws IllegalStateException if it is called
* in an order other than the one specified above
*/
public native void setDataSource(FileDescriptor fd, long offset, long length)
throws IOException, IllegalArgumentException, IllegalStateException;
'ContentDrovider' या सामग्री के लिए संपत्ति फ़ोल्डर से सामग्री से खेलते समय फ़ाइलडिस्क्रिप्टर उपयोग योग्य है। – Jens