日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[J2ME]Nokia播放音乐时发生MediaException的解决办法

發布時間:2025/4/16 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [J2ME]Nokia播放音乐时发生MediaException的解决办法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?[J2ME]Nokia播放音樂時發生MediaException的解決辦法

現象

Nokia7610上播放音樂時遇到了-18MediaException錯誤!

J2ME中播放音樂資源的代碼很容易找,我是直接從這篇比較經典的《熟練使用J2ME在實際開發中的可選包MMAPI》中復制的代碼,

心想,這總不會有錯吧?

播放媒體文件流,真機測試發生異常的代碼

????Player p = Manager.createPlayer(m_isInputImage,"audio/amr");

????p.realize();

???// Set a listener.

???p.addPlayerListener(new Listener());

???// Grab volume control for the player.

???// Set Volume to max.

???vc = (VolumeControl)p.getControl("VolumeControl");

???if (vc != null)

??????vc.setLevel(100);

???// Set a start time.

???p.setMediaTime(5 * SECS_TO_MICROSECS);

???// Guarantee that the player

???can start with the smallest latency.

???p.prefetch();

???// Non-blocking start

???p.start();

?

這段代碼在Nokia開發工具包的S60系列模擬器上順利通過!

但是,不幸的事情發生了,在真機測試中,Nokia7610彈出一個錯誤:

javax.microedition.media.MediaException: -18

?

這下,在網上根本找不到-18這個錯誤號到底代表什么。

和我有類似情況的還有houhou,他0411月報告過這個錯誤:

http://www.cnjm.net/cgi-bin/lbcjm/topic.cgi?forum=5&topic=4582

解決

原因是,Player::setMediaTime函數在Nokia 7610上不支持!

修正為以下代碼后,真機測試通過。具體的應用文檔參見:《[J2ME]手機也可以玩播客(Podcast)! Geek客說明》,源代碼下載http://files.cnblogs.com/zhengyun_ustc/toodouPodcastMidlet.rar?。

播放媒體文件流,能測試通過的代碼

???m_player = Manager.createPlayer(m_isInputImage,

????????????"audio/amr");

????// realize the player

????m_player.realize();

????System.out.println("Got player realize!");

????// Guarantee that the player??can start with the smallest latency.

????m_player.prefetch();

????System.out.println("Got player prefetch!");

??????

???// Grab volume control for the player.

???// Set Volume to max.

???m_volume = (VolumeControl)

????????m_player.getControl("VolumeControl");

???if (m_volume != null)

??????m_volume.setLevel(m_nVolume);

???System.out.println("Got VolumeControl!");

???m_player.start();

?

希望這個報告對你有參考價值。也希望你能夠告訴我-18代表著什么。

?

鄭昀@ultrapower

產品名稱

產品版本

Keyword: Mobile Media?媒體播放?j2me midp MediaException

iPodderX

Mobile

0.0.1 BETA

?

總結

以上是生活随笔為你收集整理的[J2ME]Nokia播放音乐时发生MediaException的解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。