Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
6,621 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
Mobile/platforms/ios/.staging/www/plugins/org.apache.cordova.media/www/Media.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
cordova.define("org.apache.cordova.media.Media", function(require, exports, module) { /* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
* | ||
*/ | ||
|
||
var argscheck = require('cordova/argscheck'), | ||
utils = require('cordova/utils'), | ||
exec = require('cordova/exec'); | ||
|
||
var mediaObjects = {}; | ||
|
||
/** | ||
* This class provides access to the device media, interfaces to both sound and video | ||
* | ||
* @constructor | ||
* @param src The file name or url to play | ||
* @param successCallback The callback to be called when the file is done playing or recording. | ||
* successCallback() | ||
* @param errorCallback The callback to be called if there is an error. | ||
* errorCallback(int errorCode) - OPTIONAL | ||
* @param statusCallback The callback to be called when media status has changed. | ||
* statusCallback(int statusCode) - OPTIONAL | ||
*/ | ||
var Media = function(src, successCallback, errorCallback, statusCallback) { | ||
argscheck.checkArgs('SFFF', 'Media', arguments); | ||
this.id = utils.createUUID(); | ||
mediaObjects[this.id] = this; | ||
this.src = src; | ||
this.successCallback = successCallback; | ||
this.errorCallback = errorCallback; | ||
this.statusCallback = statusCallback; | ||
this._duration = -1; | ||
this._position = -1; | ||
exec(null, this.errorCallback, "Media", "create", [this.id, this.src]); | ||
}; | ||
|
||
// Media messages | ||
Media.MEDIA_STATE = 1; | ||
Media.MEDIA_DURATION = 2; | ||
Media.MEDIA_POSITION = 3; | ||
Media.MEDIA_ERROR = 9; | ||
|
||
// Media states | ||
Media.MEDIA_NONE = 0; | ||
Media.MEDIA_STARTING = 1; | ||
Media.MEDIA_RUNNING = 2; | ||
Media.MEDIA_PAUSED = 3; | ||
Media.MEDIA_STOPPED = 4; | ||
Media.MEDIA_MSG = ["None", "Starting", "Running", "Paused", "Stopped"]; | ||
|
||
// "static" function to return existing objs. | ||
Media.get = function(id) { | ||
return mediaObjects[id]; | ||
}; | ||
|
||
/** | ||
* Start or resume playing audio file. | ||
*/ | ||
Media.prototype.play = function(options) { | ||
exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]); | ||
}; | ||
|
||
/** | ||
* Stop playing audio file. | ||
*/ | ||
Media.prototype.stop = function() { | ||
var me = this; | ||
exec(function() { | ||
me._position = 0; | ||
}, this.errorCallback, "Media", "stopPlayingAudio", [this.id]); | ||
}; | ||
|
||
/** | ||
* Seek or jump to a new time in the track.. | ||
*/ | ||
Media.prototype.seekTo = function(milliseconds) { | ||
var me = this; | ||
exec(function(p) { | ||
me._position = p; | ||
}, this.errorCallback, "Media", "seekToAudio", [this.id, milliseconds]); | ||
}; | ||
|
||
/** | ||
* Pause playing audio file. | ||
*/ | ||
Media.prototype.pause = function() { | ||
exec(null, this.errorCallback, "Media", "pausePlayingAudio", [this.id]); | ||
}; | ||
|
||
/** | ||
* Get duration of an audio file. | ||
* The duration is only set for audio that is playing, paused or stopped. | ||
* | ||
* @return duration or -1 if not known. | ||
*/ | ||
Media.prototype.getDuration = function() { | ||
return this._duration; | ||
}; | ||
|
||
/** | ||
* Get position of audio. | ||
*/ | ||
Media.prototype.getCurrentPosition = function(success, fail) { | ||
var me = this; | ||
exec(function(p) { | ||
me._position = p; | ||
success(p); | ||
}, fail, "Media", "getCurrentPositionAudio", [this.id]); | ||
}; | ||
|
||
/** | ||
* Start recording audio file. | ||
*/ | ||
Media.prototype.startRecord = function() { | ||
exec(null, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]); | ||
}; | ||
|
||
/** | ||
* Stop recording audio file. | ||
*/ | ||
Media.prototype.stopRecord = function() { | ||
exec(null, this.errorCallback, "Media", "stopRecordingAudio", [this.id]); | ||
}; | ||
|
||
/** | ||
* Release the resources. | ||
*/ | ||
Media.prototype.release = function() { | ||
exec(null, this.errorCallback, "Media", "release", [this.id]); | ||
}; | ||
|
||
/** | ||
* Adjust the volume. | ||
*/ | ||
Media.prototype.setVolume = function(volume) { | ||
exec(null, null, "Media", "setVolume", [this.id, volume]); | ||
}; | ||
|
||
/** | ||
* Audio has status update. | ||
* PRIVATE | ||
* | ||
* @param id The media object id (string) | ||
* @param msgType The 'type' of update this is | ||
* @param value Use of value is determined by the msgType | ||
*/ | ||
Media.onStatus = function(id, msgType, value) { | ||
|
||
var media = mediaObjects[id]; | ||
|
||
if(media) { | ||
switch(msgType) { | ||
case Media.MEDIA_STATE : | ||
media.statusCallback && media.statusCallback(value); | ||
if(value == Media.MEDIA_STOPPED) { | ||
media.successCallback && media.successCallback(); | ||
} | ||
break; | ||
case Media.MEDIA_DURATION : | ||
media._duration = value; | ||
break; | ||
case Media.MEDIA_ERROR : | ||
media.errorCallback && media.errorCallback(value); | ||
break; | ||
case Media.MEDIA_POSITION : | ||
media._position = Number(value); | ||
break; | ||
default : | ||
console.error && console.error("Unhandled Media.onStatus :: " + msgType); | ||
break; | ||
} | ||
} | ||
else { | ||
console.error && console.error("Received Media.onStatus callback for unknown media :: " + id); | ||
} | ||
|
||
}; | ||
|
||
module.exports = Media; | ||
|
||
}); |
57 changes: 57 additions & 0 deletions
57
Mobile/platforms/ios/.staging/www/plugins/org.apache.cordova.media/www/MediaError.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
cordova.define("org.apache.cordova.media.MediaError", function(require, exports, module) { /* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
* | ||
*/ | ||
|
||
/** | ||
* This class contains information about any Media errors. | ||
*/ | ||
/* | ||
According to :: http://dev.w3.org/html5/spec-author-view/video.html#mediaerror | ||
We should never be creating these objects, we should just implement the interface | ||
which has 1 property for an instance, 'code' | ||
instead of doing : | ||
errorCallbackFunction( new MediaError(3,'msg') ); | ||
we should simply use a literal : | ||
errorCallbackFunction( {'code':3} ); | ||
*/ | ||
|
||
var _MediaError = window.MediaError; | ||
|
||
|
||
if(!_MediaError) { | ||
window.MediaError = _MediaError = function(code, msg) { | ||
this.code = (typeof code != 'undefined') ? code : null; | ||
this.message = msg || ""; // message is NON-standard! do not use! | ||
}; | ||
} | ||
|
||
_MediaError.MEDIA_ERR_NONE_ACTIVE = _MediaError.MEDIA_ERR_NONE_ACTIVE || 0; | ||
_MediaError.MEDIA_ERR_ABORTED = _MediaError.MEDIA_ERR_ABORTED || 1; | ||
_MediaError.MEDIA_ERR_NETWORK = _MediaError.MEDIA_ERR_NETWORK || 2; | ||
_MediaError.MEDIA_ERR_DECODE = _MediaError.MEDIA_ERR_DECODE || 3; | ||
_MediaError.MEDIA_ERR_NONE_SUPPORTED = _MediaError.MEDIA_ERR_NONE_SUPPORTED || 4; | ||
// TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below. | ||
// as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes | ||
_MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4; | ||
|
||
module.exports = _MediaError; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+389 Bytes
(100%)
...ng.xcodeproj/project.xcworkspace/xcuserdata/ez.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.