aarajput / wc_flutter_share

A Flutter plugin for sharing files & text with other applications.
Apache License 2.0
35 stars 19 forks source link

Unable to share audio. And video files are shared without sound. #22

Closed sakinaboriwala closed 3 years ago

sakinaboriwala commented 4 years ago
  String text =
      "Check out this post!.\n ${postText == null ? '': postText} \n $caption \n ${SHARE_URL}post/$hashId \n Download the App here. " +
          (Platform.isIOS ? PLAY_STORE_LINK : APP_STORE_LINK);
  String fileName = imageURL.split("?")[0];

  String mimeType = lookupMimeType(fileName);
  print(mimeType);

  var response = await get(imageURL);

  WcFlutterShare.share(
      sharePopupTitle: 'share',
      text: text,
      fileName: 'image.png',
      mimeType: mimeType,
      bytesOfFile: response.bodyBytes);
aarajput commented 4 years ago

Your file name has .png extension. Try to fix it.

sakinaboriwala commented 4 years ago

@aarajput Thanks for your quick reply. will change it and get back to you!

sakinaboriwala commented 4 years ago

works well! Only one thing, unable to share text with audio file. Any fix for that too? @aarajput

aarajput commented 4 years ago

So, you are saying that property text isn't working. Right?

sakinaboriwala commented 4 years ago

Yes. It;s working when I share image and video but not for audio. @aarajput

aarajput commented 4 years ago

Try using breakpoint and share your text here incase of audio share.

sakinaboriwala commented 4 years ago
Future shareContent(String hashId, BuildContext context,
    {String fileURL, String postText, String caption}) async {

  String text =
      "Check out this post!.\n ${postText == null ? '' : postText} \n $caption \n ${SHARE_URL}post/$hashId \n Download the App here. " +
          (Platform.isIOS ? APP_STORE_LINK : PLAY_STORE_LINK);
  String fileName = fileURL.split("?")[0];

  RegExp regexp = RegExp(r"\.[a-zA-Z]*$", caseSensitive: false);
  String timestamp = new DateTime.now().millisecondsSinceEpoch.toString();

  String ext = regexp.stringMatch(fileName);
  String mimeType = lookupMimeType(fileName);

  var response = await get(imageURL);
  ScopedModel.of<MainModel>(context, rebuildOnChange: true)
      .setIsPostsLoading(false);

  WcFlutterShare.share(
      sharePopupTitle: 'share',
      text: text,
      fileName: "file" + timestamp + ext,
      mimeType: mimeType,
      bytesOfFile: response.bodyBytes);

}
sakinaboriwala commented 4 years ago

The above code is generic for all 3 cases. @aarajput

sakinaboriwala commented 4 years ago

Heyy @aarajput Any input would be highly appreciated.

aarajput commented 4 years ago

Sorry @sakina1403 ! With which application you are trying to share audio file?

sakinaboriwala commented 4 years ago

I am just glad you are replying :) At present I have tried with WhatsApp.

aarajput commented 4 years ago

Sorry @sakina1403 ! I didnt get time to look into this myself. Try it with gmail and let me know. Because it could be whats app issue.

albemala commented 4 years ago

@sakina1403 Not being able to share text+audio in Whatsapp should be a limitation of Whatsapp. If you try to share text+audio with GMail, for example, it should work.

aarajput commented 3 years ago

I am closing this issue as it seems to be issue with whats app only.