提交 e13b0eeb 编写于 作者: 杜庆泉's avatar 杜庆泉

add res button

上级 5f6f1453
......@@ -2,8 +2,8 @@
"name" : "HelloUTS",
"appid" : "__UNI__70BE9D0",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"versionName" : "1.0.1",
"versionCode" : "101",
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
......
......@@ -10,7 +10,7 @@
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="testAddToDecorView">添加TextView至视图顶层</button>
<button type="primary" @tap="testRemoveToDecorView">移除视图顶层的TextView</button>
<button type="primary" @tap="testLoadImage">资源加载示例</button>
<button type="primary" @tap="testResource">资源加载示例</button>
<button type="primary" @tap="testLifecyle">activity生命周期监听</button>
</view>
......@@ -84,7 +84,7 @@
removeViewToDecorView();
},
testLoadImage: function () {
testResource: function () {
uni.navigateTo({
url:'/pages/resource/resource'
})
......
......@@ -3,14 +3,15 @@
<page-head :title="title"></page-head>
<image :src="logo" mode="aspectFit" style="width: 100%;"></image>
<view class="uni-btn-v uni-common-mt">
<button type="primary" >插件内置图片</button>
<button type="primary" @tap="testAssetLoad" >asset资源加载</button>
<button type="primary" >展示插件内置图片</button>
<button type="primary" @tap="testAssetLoad" >播放asset音频(需自定义基座)</button>
<button type="primary" @tap="testResText" >获取res目录资源(需自定义基座)</button>
</view>
</view>
</template>
<script>
import { getLogoPath,getAssetAPath } from '../../uni_modules/uts-advance'
import { getLogoPath,playAssetAudio,getResText } from '../../uni_modules/uts-advance'
export default {
......@@ -25,8 +26,11 @@
},
methods: {
testAssetLoad(){
let aseetPath = getAssetAPath();
console.log(aseetPath);
playAssetAudio();
},
testResText(){
let resText = getResText();
console.log(resText);
}
}
......
......@@ -4,4 +4,4 @@
"dependencies": [{
}],
"minSdkVersion": 21
},
\ No newline at end of file
}
\ No newline at end of file
......@@ -113,17 +113,25 @@ export function getLogoPath(): string {
}
export function getAssetAPath() {
export function playAssetAudio() {
var assetManager = getAppContext()!.getAssets();
var afd = assetManager.openFd("free.mp3");
var mediaPlayer = new MediaPlayer();
let assetManager = getAppContext()!.getAssets();
let afd = assetManager.openFd("free.mp3");
let mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(), afd.getLength());
mediaPlayer.prepare();
mediaPlayer.start();
}
const RTEXT:number = 10020;
export function getResText() :string{
// let text = "aaa " + com.sina.weibo.sdk.R2.string.com_sina_weibo_sdk_logout;
// let resText = getAppContext()!.getString(io.dcloud.uni_modules.uts_advance.R.string.dcloud_common_app_res_download_failed)
return "222";
}
......
<resources>
<string name="uts_resource_text">Chinese Text</string>
</resources>
\ No newline at end of file
<resources>
<string name="uts_resource_text">English Text</string>
</resources>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册