RecordRTC.js
function() {
        var self = this;

        if (typeof indexedDB === 'undefined' || typeof indexedDB.open === 'undefined') {
            console.error('IndexedDB API are not available in this browser.');
            return;
        }

        var dbVersion = 1;
        var dbName = this.dbName || location.href.replace(/\/|:|#|%|\.|\[|\]/g, ''),
            db;
        var request = indexedDB.open(dbName, dbVersion);

        function createObjectStore(dataBase) {
            dataBase.createObjectStore(self.dataStoreName);
        }

        function putInDB() {
            var transaction = db.transaction([self.dataStoreName], 'readwrite');

            if (self.videoBlob) {
                transaction.objectStore(self.dataStoreName).put(self.videoBlob, 'videoBlob');
            }

            if (self.gifBlob) {
                transaction.objectStore(self.dataStoreName).put(self.gifBlob, 'gifBlob');
            }

            if (self.audioBlob) {
                transaction.objectStore(self.dataStoreName).put(self.audioBlob, 'audioBlob');
            }

            function getFromStore(portionName) {
                transaction.objectStore(self.dataStoreName).get(portionName).onsuccess = function(event) {
                    if (self.callback) {
                        self.callback(event.target.result, portionName);
                    }
                };
            }

            getFromStore('audioBlob');
            getFromStore('videoBlob');
            getFromStore('gifBlob');
        }

        request.onerror = self.onError;

        request.onsuccess = function() {
            db = request.result;
            db.onerror = self.onError;

            if (db.setVersion) {
                if (db.version !== dbVersion) {
                    var setVersion = db.setVersion(dbVersion);
                    setVersion.onsuccess = function() {
                        createObjectStore(db);
                        putInDB();
                    };
                } else {
                    putInDB();
                }
            } else {
                putInDB();
            }
        };
        request.onupgradeneeded = function(event) {
            createObjectStore(event.target.result);
        };
    }
function() {
        var self = this;

        if (typeof indexedDB === 'undefined' || typeof indexedDB.open === 'undefined') {
            console.error('IndexedDB API are not available in this browser.');
            return;
        }

        var dbVersion = 1;
        var dbName = this.dbName || location.href.replace(/\/|:|#|%|\.|\[|\]/g, ''),
            db;
        var request = indexedDB.open(dbName, dbVersion);

        function createObjectStore(dataBase) {
            dataBase.createObjectStore(self.dataStoreName);
        }

        function putInDB() {
            var transaction = db.transaction([self.dataStoreName], 'readwrite');

            if (self.videoBlob) {
                transaction.objectStore(self.dataStoreName).put(self.videoBlob, 'videoBlob');
            }

            if (self.gifBlob) {
                transaction.objectStore(self.dataStoreName).put(self.gifBlob, 'gifBlob');
            }

            if (self.audioBlob) {
                transaction.objectStore(self.dataStoreName).put(self.audioBlob, 'audioBlob');
            }

            function getFromStore(portionName) {
                transaction.objectStore(self.dataStoreName).get(portionName).onsuccess = function(event) {
                    if (self.callback) {
                        self.callback(event.target.result, portionName);
                    }
                };
            }

            getFromStore('audioBlob');
            getFromStore('videoBlob');
            getFromStore('gifBlob');
        }

        request.onerror = self.onError;

        request.onsuccess = function() {
            db = request.result;
            db.onerror = self.onError;

            if (db.setVersion) {
                if (db.version !== dbVersion) {
                    var setVersion = db.setVersion(dbVersion);
                    setVersion.onsuccess = function() {
                        createObjectStore(db);
                        putInDB();
                    };
                } else {
                    putInDB();
                }
            } else {
                putInDB();
            }
        };
        request.onupgradeneeded = function(event) {
            createObjectStore(event.target.result);
        };
    }
function ( ) { var self = this ; if ( typeof indexedDB === 'undefined' || typeof indexedDB . open === 'undefined' ) { console . error ( 'IndexedDB API are not available in this browser.' ) ; return ; } var dbVersion = 1 ; var dbName = this . dbName || location . href . replace ( / \/|:|#|%|\.|\[|\] / g , '' ) , db ; var request = indexedDB . open ( dbName , dbVersion ) ; function createObjectStore ( dataBase ) { dataBase . createObjectStore ( self . dataStoreName ) ; } function putInDB ( ) { var transaction = db . transaction ( [ self . dataStoreName ] , 'readwrite' ) ; if ( self . videoBlob ) { transaction . objectStore ( self . dataStoreName ) . put ( self . videoBlob , 'videoBlob' ) ; } if ( self . gifBlob ) { transaction . objectStore ( self . dataStoreName ) . put ( self . gifBlob , 'gifBlob' ) ; } if ( self . audioBlob ) { transaction . objectStore ( self . dataStoreName ) . put ( self . audioBlob , 'audioBlob' ) ; } function getFromStore ( portionName ) { transaction . objectStore ( self . dataStoreName ) . get ( portionName ) . onsuccess = function ( event ) { if ( self . callback ) { self . callback ( event . target . result , portionName ) ; } } ; } getFromStore ( 'audioBlob' ) ; getFromStore ( 'videoBlob' ) ; getFromStore ( 'gifBlob' ) ; } request . onerror = self . onError ; request . onsuccess = function ( ) { db = request . result ; db . onerror = self . onError ; if ( db . setVersion ) { if ( db . version !== dbVersion ) { var setVersion = db . setVersion ( dbVersion ) ; setVersion . onsuccess = function ( ) { createObjectStore ( db ) ; putInDB ( ) ; } ; } else { putInDB ( ) ; } } else { putInDB ( ) ; } } ; request . onupgradeneeded = function ( event ) { createObjectStore ( event . target . result ) ; } ; }
This method must be called once to initialize IndexedDB ObjectStore. Though, it is auto-used internally.
@method
@memberof DiskStorage
@internal
@example
DiskStorage.init();
This method must be called once to initialize IndexedDB ObjectStore . Though it is auto - used internally .