【前提条件】:

【操作步骤】:接收一条音频(系统音频,格式为ogg),点菜单键选择View slideshow

【测试结果】:不能播放,提示是否导入vCard

【预期结果】:可以播放

【备注】:附log  接收带图片、ogg格式音频 、视频幻灯片时也不能播放,提示是否导入vCard

经过分析和反复测试发现,该问题是由于电信运营商引起,该问题为移动发往本机联通网络,接收类型为application/oct-stream,但文件扩展名为ogg格式音频,因此导致该问题的产生,为了更全面的解决该模块下彩信接收功能这种有电信运营商之间的不兼容产生的问题,同时测试不同类型附件包括视频/音频/图片/名片等,在同时接受中国移动电信运营商发来的附件(包括图片/视频/音频等)测试发现,只有音频出现了类似的问题,因此在经过分析发现在获取接受附件的MIME是发现,vcard和ogg音频的contentType都是oct-stream;下面是数据截图:

因此我们在SlideshowModel类中的createFromMessageUri()方法中添加对附件文件扩展名的判断(红色为修改添加的内容);

public static SlideshowModel createFromPduBody(Context context, PduBody pb) throws MmsException {

        SMILDocument document = SmilHelper.getDocument(pb);



        // Create root-layout model.

        SMILLayoutElement sle = document.getLayout();

        SMILRootLayoutElement srle = sle.getRootLayout();

        int w = srle.getWidth();

        int h = srle.getHeight();

        if ((w == 0) || (h == 0)) {

            w = LayoutManager.getInstance().getLayoutParameters().getWidth();

            h = LayoutManager.getInstance().getLayoutParameters().getHeight();

            srle.setWidth(w);

            srle.setHeight(h);

        }

        RegionModel rootLayout = new RegionModel(

                null, 0, 0, w, h);



        // Create region models.

        ArrayList<RegionModel> regions = new ArrayList<RegionModel>();

        NodeList nlRegions = sle.getRegions();

        int regionsNum = nlRegions.getLength();



        for (int i = 0; i < regionsNum; i++) {

            SMILRegionElement sre = (SMILRegionElement) nlRegions.item(i);

            RegionModel r = new RegionModel(sre.getId(), sre.getFit(),

                    sre.getLeft(), sre.getTop(), sre.getWidth(), sre.getHeight(),

                    sre.getBackgroundColor());

            regions.add(r);

        }

        LayoutModel layouts = new LayoutModel(rootLayout, regions);



        // Create slide models.

        SMILElement docBody = document.getBody();

        NodeList slideNodes = docBody.getChildNodes();

        int slidesNum = slideNodes.getLength();

        ArrayList<SlideModel> slides = new ArrayList<SlideModel>(slidesNum);

        int totalMessageSize = 0;

        boolean classCastFailed = false;



        for (int i = 0; i < slidesNum; i++) {

            // FIXME: This is NOT compatible with the SMILDocument which is

            // generated by some other mobile phones.

            SMILParElement par = (SMILParElement) slideNodes.item(i);



            // Create media models for each slide.

            NodeList mediaNodes = par.getChildNodes();

            int mediaNum = mediaNodes.getLength();

            ArrayList<MediaModel> mediaSet = new ArrayList<MediaModel>(mediaNum);



            for (int j = 0; j < mediaNum; j++) {

                SMILMediaElement sme = null;

                try {

                    sme = (SMILMediaElement) mediaNodes.item(j);

                } catch (ClassCastException e) {

                    classCastFailed = true;

                    Log.e(TAG, e.getMessage());

                    continue;

                }

                try {

                    MediaModel media = MediaModelFactory.getMediaModel(

                            context, sme, layouts, pb);



                    /*

                    * This is for slide duration value set.

                    * If mms server does not support slide duration.

                    */

                    if (!MmsConfig.getSlideDurationEnabled()) {

                        int mediadur = media.getDuration();

                        float dur = par.getDur();

                        if (dur == 0) {

                            mediadur = MmsConfig.getMinimumSlideElementDuration() * 1000;

                            media.setDuration(mediadur);

                        }



                        if ((int)mediadur / 1000 != dur) {

                            String tag = sme.getTagName();



                            if (ContentType.isVideoType(media.mContentType)

                              || tag.equals(SmilHelper.ELEMENT_TAG_VIDEO)

                              || ContentType.isAudioType(media.mContentType)

                              || tag.equals(SmilHelper.ELEMENT_TAG_AUDIO)) {

                                /*

                                * add 1 sec to release and close audio/video

                                * for guaranteeing the audio/video playing.

                                * because the mmsc does not support the slide duration.

                                */

                                par.setDur((float)mediadur / 1000 + 1);

                            } else {

                                /*

                                * If a slide has an image and an audio/video element

                                * and the audio/video element has longer duration than the image,

                                * The Image disappear before the slide play done. so have to match

                                * an image duration to the slide duration.

                                */

                                if ((int)mediadur / 1000 < dur) {

                                    media.setDuration((int)dur * 1000);

                                } else {

                                    if ((int)dur != 0) {

                                        media.setDuration((int)dur * 1000);

                                    } else {

                                        par.setDur((float)mediadur / 1000);

                                    }

                                }

                            }

                        }

                    }

                    SmilHelper.addMediaElementEventListeners(

                            (EventTarget) sme, media);

                    mediaSet.add(media);

                    totalMessageSize += media.getMediaSize();

                } catch (IOException e) {

                    Log.e(TAG, e.getMessage(), e);

                } catch (IllegalArgumentException e) {

                    Log.e(TAG, e.getMessage(), e);

                }

            }

            // Add vcard and vcalendar when receive from other products

            // without ref target in smil.

            int partsNum = pb.getPartsNum();

            for (int k = 0; k < partsNum; k++) {

                PduPart part = pb.getPart(k);

                String type=new String(part.getContentType());

                if (type.toLowerCase().equals(ContentType.TEXT_VCARD.toLowerCase())||(type.toLowerCase().equals(ContentType.OCT_STREAM)&&isVCF(new String(part.getContentLocation())))) {

                    MediaModel vMedia = new VcardModel(context, new String(

                            part.getContentType()), new String(part.getContentLocation()),

                            part.getDataUri());

                    mediaSet.add(vMedia);

                    totalMessageSize += vMedia.getMediaSize();

                    break;

                }else if (type.toLowerCase().equals(ContentType.TEXT_VCALENDAR.toLowerCase())) {

                    MediaModel tMedia = new UnsupportModel(context, new String(

                            part.getContentType()), new String(part.getContentLocation()),

                            part.getDataUri());

                    mediaSet.add(tMedia);

                    totalMessageSize += tMedia.getMediaSize();

                    break;

                }

            }

            float duration = par.getDur();

            if (duration < MIN_PAT_DURATION) {

                duration = MIN_PAT_DURATION;

            }

            SlideModel slide = new SlideModel((int) (duration * 1000), mediaSet);

            slide.setFill(par.getFill());

            SmilHelper.addParElementEventListeners((EventTarget) par, slide);

            slides.add(slide);

        }



        SlideshowModel slideshow = new SlideshowModel(layouts, slides, document, pb, context);

        slideshow.mTotalMessageSize = totalMessageSize;

        slideshow.registerModelChangedObserver(slideshow);

        return slideshow;

    }

    /**

     * @param fileName

     * @return

     */

    public static boolean isVCF(String fileName) {

        if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) {

            return( fileName.substring(fileName.lastIndexOf(".") + 1)).toLowerCase().equals("vcf");

        } else {

            return false;

        }

    }

接收一条音频(系统音频)彩信,点菜单键选择View slideshow,不能播放,提示是否导入vCard的更多相关文章

  1. 解决:编辑一条彩信,附件选择添加音频,返回到编辑界面选择play,不能播放,没有声音

    [操作步骤]:编辑一条彩信,附件选择添加音频(外部音频),返回到编辑界面选择play,菜单键选择view slideshow [测试结果]:不能播放,没有声音 [预期结果]:可以播放 根据以往的经验( ...

  2. Android音频系统之音频框架

    1.1 音频框架 转载请注明,From LXS, http://blog.csdn.net/uiop78uiop78/article/details/8796492 Android的音频系统在很长一段 ...

  3. Android音频系统之AudioPolicyService

    地址:http://blog.csdn.net/edmond999/article/details/18599327 1.1 AudioPolicy Service 在AudioFlinger小节,我 ...

  4. Android音频系统之AudioFlinger(一)

    1.1 AudioFlinger 在上面的框架图中,我们可以看到AudioFlinger(下面简称AF)是整个音频系统的核心与难点.作为Android系统中的音频中枢,它同时也是一个系统服务,启到承上 ...

  5. 转:ANDROID音频系统散记之四:4.0音频系统HAL初探

    昨天(2011-11-15)发布了Android4.0的源码,今天download下来,开始挺进4.0时代.简单看了一下,发现音频系统方面与2.3的有较多地方不同,下面逐一描述. 一.代码模块位置 1 ...

  6. macOS实现视频转音频以及音频拼接

    macOS实现视频转音频以及音频拼接 ffmpeg 的安装 终端输入以下指令: brew install ffmpeg 视频转音频 终端输入以下指令: ffmpeg -i 视频名称.flv -vn - ...

  7. 分享macOS平台好用的视频分割、合并视频、提取音频、分离音频、音频转码的工具CCVideo

    CCVideo 是一款运行在macOS上可分割视频(可多段分割).合并视频.提取音频.分离音频.音频转码的工具,操作方便,只需简单几步,便可轻松完成. 下载地址

  8. 禁止Centos系统You have new mail in /var/spool/mail/root提示

    禁止Centos系统You have new mail in /var/spool/mail/root提示 https://blog.csdn.net/oyym_mv/article/details/ ...

  9. Android音频系统之AudioFlinger(二)

    1.1.1 音频设备的管理 虽然AudioFlinger实体已经成功创建并初始化,但到目前为止它还是一块静态的内存空间,没有涉及到具体的工作. 从职能分布上来讲,AudioPolicyService是 ...

随机推荐

  1. 如何解决Visual Studio2010 编译时提示系统找不到指定文件问题

    前一段时间,开始使用vs2010编写程序,可是在编译的时候总是报错,提示系统找不到指定文件,导致无法正常运行程序,花了好久时间终于找到原因解决,是因为常规的输出目录 要与链接的常规的输出文件要相对应. ...

  2. HDU 6083 度度熊的午饭时光(01背包+记录路径)

    http://acm.hdu.edu.cn/showproblem.php?pid=6083 题意: 思路: 01背包+路径记录. 题目有点坑,我一开始逆序枚举菜品,然后一直WA,可能这样的话路径记录 ...

  3. 【Python】【元编程】【二】【描述符】

    """ #描述符实例是托管类的类属性:此外,托管类还有自己实例的同名属性 #20.1.1 LineItem类第三版:一个简单的描述符#栗子20-1 dulkfood_v3 ...

  4. codeforces804D Expected diameter of a tree

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  5. MongoDB(课时8 模运算)

    3.4.2.3 求模 模运算使用“$mod”来完成,语法: {$mod : [除数,余数]} 范例:求模 db.students.find({"age" : {"$mod ...

  6. matplotlib-绘制精美的图表

    matplotlib库链接:http://matplotlib.org/gallery.html matplotlib绘制精美图标链接:http://old.sebug.net/paper/books ...

  7. fragment 小结

    1:注意事项   3.0以前的Android 版本要使用FragmentActivity 来装载Fragment ,使用到support v4包.   3.0以后的版本可以直接在Activity里面添 ...

  8. Codeforces 454D - Little Pony and Harmony Chest

    454D - Little Pony and Harmony Chest 思路: 状压dp,由于1的时候肯定满足题意,而ai最大是30,所以只要大于等于59都可以用1替换,所以答案在1到59之间 然后 ...

  9. Codeforces 525A - Vitaliy and Pie

    525A - Vitaliy and Pie 思路:贪心+hashing. 代码: #include<bits/stdc++.h> using namespace std; string ...

  10. Android 使用SQLite

    SQLite简介 Google为Andriod的较大的数据处理提供了SQLite,他在数据存储.管理.维护等各方面都相当出色,功能也非常的强大.SQLite具备下列特点: 1.轻量级 使用 SQLit ...