Wrong DURATION in MediaStore.Video.Media.DURATION

前端 未结 1 1428
猫巷女王i
猫巷女王i 2021-01-25 23:49

I\'m trying to record video in my application and I\'ve noticed that displaying their duration, I see wrong minutes \\ seconds. This happens on

相关标签:
1条回答
  • 2021-01-26 00:21

    solved in this way:

        MediaPlayer mp = MediaPlayer.create(this, Uri.parse(outputfilename));
        int duration = mp.getDuration();
        mp.release();
    
        ContentValues values = new ContentValues();
        values.put(MediaStore.Video.Media.DATA, outputfilename);
        values.put(MediaStore.Video.Media.DATE_TAKEN, dateTaken);
        values.put(MediaStore.Video.Media.DURATION, duration);
    

    It was the need to calculate and add the video duration to the MediaStore properties.

    0 讨论(0)
提交回复
热议问题