eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 170 forks source link

cordova media plugin not work on android! #1913

Open Nexter-day opened 5 years ago

Nexter-day commented 5 years ago

Problem description

I tried to play media on android using the cordova media plugin,

But it doesn't work (ios works). I have tried many times, but I can't solve it. Is there anyone who can help me?

Expected behavior

With the official example, extract part of the code, ios work, android has not been successful

Environment

Code snippet

const { Page,Button,app,ImageView,ui,WebView,contentView,Composite,ScrollView,Canvas,device,Popover,TextView,StatusBar} = require('tabris');

document.addEventListener("deviceready", onDeviceReady, true);
function onDeviceReady() {
  console.log(Media);

}
var path1 = tabris.app.getResourceLocation("src/assets/media/media.wav");
var path2 =tabris.app.getResourceLocation("android_asset/www/media/media.wav");

function playAudio(url) {

  var my_media = new Media(url,
    // success callback
    function () {
      console.log("playAudio():Audio Success");
    },
    // error callback
    function (err) {
    console.log(JSON.stringify(err))
      console.log("playAudio():Audio Error: " + err);
    }
  );
  // Play audio

  my_media.play();
  my_media.setVolume('1.0');
}

new Button({
  left: 10, top: 10,
  text: 'Button'
}).on('select', ()=>playAudio(path1))
  .appendTo(ui.contentView);

new Button({
  left: 10, top: 10,
  text: 'Button'
}).on('select', ()=>playAudio(path2))
  .appendTo(ui.contentView);
mpost commented 5 years ago

Unfortunatly we can not provide support for third party plugins. In case of media playback we have will provide audio support via https://github.com/eclipsesource/tabris-js/issues/1888.

Nexter-day commented 5 years ago

Video widgets is an easy way,but how can I set the video volume? It doesn't seem to have this option

mpost commented 5 years ago

that is correct. you could open an issue for a feature request.

cookieguru commented 5 years ago

@Nexter-day There's also cordova-plugin-android-volume and cordova-plugin-volume-control. Note that the latter can be used on iOS, but Apple will reject submissions to the App Store.

ishigo1987 commented 4 years ago

Maybe one of the solutions would be to see why the media plugin that worked well on the old versions of TabrisJs doesn't work at all on the new versions