From: Lukasz Foniok Date: Mon, 7 Dec 2015 16:47:28 +0000 (+0100) Subject: [Media] Sample application, play, seekTo, volume, stop implemented. X-Git-Tag: submit/tizen/20151221.111205^2~4^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba41bfbe0724ae9232e3feaa78de4acdbb086b3f;p=platform%2Fcore%2Fapi%2Fcordova-plugins.git [Media] Sample application, play, seekTo, volume, stop implemented. Change-Id: I46ee8839a96789c23526d14b565c42cb830c0961 Signed-off-by: Lukasz Foniok --- diff --git a/sample/plugins/media/media.css b/sample/plugins/media/media.css index fca8a41..8ebf97f 100644 --- a/sample/plugins/media/media.css +++ b/sample/plugins/media/media.css @@ -271,17 +271,6 @@ textarea { color:#639ecd; word-wrap:break-word; } -#progressBar { - border:1px solid #aaa; - color:#34baa4; - height:20px; -} - -#progress { - background-color:#b53e3e; - height:20px; - display:inline-block; -} input { width:100%; @@ -305,7 +294,7 @@ input { width:30% } -input[type=range] +#volume[type=range] { writing-mode: bt-lr; /* IE */ -webkit-appearance: slider-vertical; /* WebKit */ diff --git a/sample/plugins/media/media.html b/sample/plugins/media/media.html index a55fe51..465627f 100644 --- a/sample/plugins/media/media.html +++ b/sample/plugins/media/media.html @@ -41,17 +41,18 @@

Filename:

- +
-
- +
+
- + @@ -70,48 +71,12 @@ 2. - Test2.wav - - - 2. - Test2.wav - - - 2. - Test2.wav - - - 2. - Test2.wav - - - 2. - Test2.wav - - - 2. - Test2.wav - - - 2. - Test2.wav - - - 2. - Test2.wav - - - 2. - Test2.wav - - - 2. - Test2.wav + /opt/usr/media/Documents/BlueZedEx.mp3
-

Commands' output:

+

Commands' output:

Back
diff --git a/sample/plugins/media/media.js b/sample/plugins/media/media.js index caeac29..fa3326b 100644 --- a/sample/plugins/media/media.js +++ b/sample/plugins/media/media.js @@ -14,6 +14,11 @@ * limitations under the License. */ +var media; +var myinterval; +var table; +var lastIndex; + var deviceReady = function() { window.logger.log('Device ready'); }; @@ -27,7 +32,7 @@ var init = function () { window.onload = init; $(document).ready(function() { - var table = $('#example').DataTable({ + table = $('#example').DataTable({ select: 'single', bLengthChange: false, paging: true, @@ -36,6 +41,24 @@ $(document).ready(function() { scrollY: 100, scroller: true }); + + table.on( 'select', function ( e, dt, type, indexes ) { + if ( type === 'row' ) { + //var data = table.row( indexes ).data().pluck( 'id' ); + //window.logger.log(table.row(indexes).data()[1]); + document.getElementById('inputFile').value = table.row(indexes).data()[1]; + if(media!=null){ + release(); + } + create(); + lastIndex = table.row(indexes).data()[0].split("")[0]; + window.logger.log("last index " + lastIndex); + } + }); + + table.on('added', function(){ + window.logger.log("dupa"); + }); } ); var success = function() { @@ -46,9 +69,6 @@ var error = function(e) { window.logger.log(e); }; -var media; -var myinterval; - function status(s, pos) { window.logger.log('status: ' + s + ', pos: ' + pos); if (s === Media.MEDIA_STOPPED) { @@ -79,13 +99,13 @@ function updateProgress() { var progress = document.getElementById('progress'), value = 0; media.getCurrentPosition(function(pos) { - window.logger.log('Get current position success 100 / ' + media.duration + " * " + console.log('Get current position success 1000 / ' + media.getDuration() + " * " + pos); if (pos > 0) { - value = Math.floor((100 / media.getDuration()) * pos); + value = Math.floor((1000 / media.getDuration()) * pos); } - progress.style.width = value + '%'; - window.logger.log('width: ' + progress.style.width); + progress.value = value; + window.logger.log('width: ' + progress.value); }); } @@ -102,10 +122,11 @@ function play() { window.logger.log('Error ' + e); } } else { - playBtn.textContent = '|>'; + playBtn.textContent = '|>'; window.logger.log('Pausing: '); try { media.pause(); + clearInterval(myinterval); } catch (e) { window.logger.log("Error " + e); } @@ -137,28 +158,27 @@ function getPos() { }); } -function setPos() { - var pos = document.getElementById('setPosValue').value; - window.logger.log('setPos'); - media.seekTo(pos); +function setPos(value) { + //var pos = document.getElementById('setPosValue').value; + clearInterval(myinterval); + //value = Math.floor((1000 / media.getDuration()) * pos); + var pos = value * media.getDuration() / 1000; + console.log('setPos to ' + value + "*" + media.getDuration() + "/ 1000 = " + pos ); + media.seekTo(pos*1000); + myinterval = setInterval(updateProgress, 100); } -function setVolume() { - var volume = document.getElementById('setVolValue').value; +function setVolume(value) { window.logger.log('setVol: ' + volume); + var volume = value / 10; media.setVolume(volume); } -function expand() { - window.logger.log('expand'); - var progress = document.getElementById('progress'); - window.logger.log('width: ' + progress.style.width); - progress.style.width = 40 + '%'; -} - function recordAudio() { window.logger.log('recordAudio'); - media.startRecord(); + create(); + table.row.add([ '2.', media.src ]).draw(false); + //media.startRecord(); } function stopRecAudio() {